PHP对象有值,但当我尝试在FOREACH()中使用它时,得到的是NULL值

PHP对象有值,但当我尝试在FOREACH()中使用它时,得到的是NULL值,php,soap,Php,Soap,我正在编写一个php应用程序,它与公司的SOAP API接口。我正在对其中一个API函数进行调用,并收到一个返回的对象。但是,当我尝试对其中一个对象变量使用foreach时,我收到了错误: 警告:为中的foreach()提供的参数无效 我的代码: // Make Call and get result $result = $soapClient->GetProgramSemesterCategoryList(array("semesterGuid" => "8725a32b-e671

我正在编写一个php应用程序,它与公司的SOAP API接口。我正在对其中一个API函数进行调用,并收到一个返回的对象。但是,当我尝试对其中一个对象变量使用foreach时,我收到了错误:

警告:为中的foreach()提供的参数无效

我的代码:

// Make Call and get result
$result = $soapClient->GetProgramSemesterCategoryList(array("semesterGuid" => "8725a32b-e671-4386-ae70-969a6d600f31"));

// Output the result
print("<b>Result = ");
print_r($result);
print("</b></br>");

// Make sure not getting an exception
if($result->GetProgramSemesterCategoryListResult->IsException)
{
    print("Error!");
}
else
{
    // Output the type of the CategoryInfo in the object
    print("<b>TYPE: " . gettype($result->GetProgramSemesterCategoryList->Value->CategoryInfo) . "</b></br>");
    foreach($result->GetProgramSemesterCategoryList->Value->CategoryInfo as $category)
    {
        print("<b>Categories for this Semester</b></br>");

        print("<b>CategoryId:</b> " . $category->CategoryId . " - <b>CategoryGuid:</b> "
            . $category->CategoryName . " - <b>CategoryName:</b> " . $category->CategoryDesc
            . " - <b>ModuleFor:</b> " . $category->ModuleFor . "</br></br>");
    }
}
下面是gettype调用显示的内容:

TYPE = NULL

您正在使用不同的对象名称。在foreach中有GetProgramSeMeterCategoryList,但对象有GetProgramSeMeterCategoryListResult。请注意末尾的“结果”。

您使用的是不同的对象名称。在foreach中有GetProgramSeMeterCategoryList,但对象有GetProgramSeMeterCategoryListResult。注意结尾的“结果”

TYPE = NULL