我将一个对象转换为数组,之后我无法通过键访问结果数组。
这是代码
print_r($new);
$new = (array)$new;
echo $new['EPPContactemail'];
foreach($new as $attr=>$value)
{
echo "$attr => $value \n";
}
输出是
EPPContact Object
(
[id:EPPContact:private] => 6553377C74FC9899
[roid:EPPContact:private] => 50085436-UK
[status:EPPContact:private] => ok
[voice:EPPContact:private] => +44.554545454
[email:EPPContact:private] => some@email.com
[fax:EPPContact:private] =>
[clID:EPPContact:private] => TSOHOST
[crID:EPPContact:private] => EPP-TSOHOST
[crDate:EPPContact:private] => 2013-07-17T09:53:41
)
Notice: Undefined index: EPPContactemail in /home/parvhraban/domains/src/local_libs/EPP/Builder/Contact/Update.php on line 9
EPPContactid => 6553377C74FC9899
EPPContactroid => 50085436-UK
EPPContactstatus => ok
EPPContactvoice => +44.554545454
EPPContactemail => some@email.com
EPPContactfax =>
EPPContactclID => TSOHOST
EPPContactcrID => EPP-TSOHOST
EPPContactcrDate => 2013-07-17T09:53:41
我可以清楚地看到 EPPContactemail 键存在并保存该值,尽管在访问它时(第 3 行,echo 语句)它会引发未定义索引的错误。
你能解释一下导致这种行为的原因吗?