所以我遇到了一个奇怪的问题,即函数不是通过引用参数传递来定义的,但是对象正在以我无法解释的方式进行更改。我已经验证函数定义不会一次又一次地通过引用。我从数据库中检索了一个对象。然后我在那个初始对象上运行了一个分析函数。我已将该对象复制到另一个变量。然后我在副本而不是原件上运行不同的分析功能。运行第二个分析函数似乎改变了第一个变量对象。关于这里可能发生的事情的任何想法。我一直在尝试调试这个几个小时,但我无法解释这种行为。我不想发布实际功能,因为它们是专有信息,但是,我可以私下发送它们以寻求帮助。
//get object from db
$resp= json_decode($ln->getResponseFromDb($resultid));
//run pwf analysis function
$resp = $ln->pwfBGCheck($resp);
//show result after pwf
print_r($resp->pwf);
/* shows
* stdClass Object ( [status] => p [reason] => Person has no c record. )
*/
//copy to another variable
$r2 = $resp;
//run pwf for s record other variable so it is not touching the first one!
$r2 = $ln->pwfBGCheckSexOffender2($r2);
echo '<BR>this is first variable<BR>';
print_r($resp->pwf);
/* copies from second to first for some reason... no pass by reference on this call... resp variable has not been touched!
* stdClass Object ( [status] => p [reason] => Person has no s record. )
*/
echo '<BR>this is second<BR>';
print_r($r2->pwf);
/* returns
* stdClass Object ( [status] => p [reason] => Person has no s record. )
*/