我从一位前同事那里继承了一些代码,并且由于它最近已投入生产,因此给我们带来了一些问题。我不是 php 开发人员,如果这看起来含糊不清,我深表歉意,但它已经落到我头上了(不要问!)。
我们正在调用一个函数getLoan()
来从现有应用程序中预填充应用程序表单。这应该返回一个数组,但我收到 stdClass 错误。
$result = getLoan(); //this is the line that is erroring
if (isset($result->GetResult->Debtor->Addresses->Address[0])) $current_address = clone $result->GetResult->Debtor->Addresses->Address[0];
else $current_address = clone $result->GetResult->Debtor->Addresses->Address;
if ($result === false)
{
echo("No LID given");
die;
}
$attr = 'selected';
和功能:
function getLoan() {
//globals
/*
global $client;
global $test;
global $result;
*/
global $thisurl;
if (isset($_GET['LID']))
$pLoanID = $_GET['LID'];
else
return false;
$test = array(
"pLoanID" => $pLoanID,
);
//print_r($Address); //print address object as a test
//send to gateway starts**********
$url = "https://www.blahblah.asmx?WSDL";
$client = new SoapClient($url, array("trace" => 1, "exception" => 0));
try {
$result = $client->Get($test);
}
catch(Exception $e) {
//header("Location: http://" . $_SERVER['REMOTE_ADDR'] . "/application-form-new");
print_r($e);
exit;
}
$thisurl = "continue-app?LID=" . $pLoanID;
if (isset($result)) return $result;
else return false;
}
如何将函数的返回值作为数组分配给 $result?
非常感谢