【发布时间】:2015-10-30 10:58:51
【问题描述】:
我有一个对象,我打印一个属性的值:
echo $myObject->field_seo_multidomain->$lang_arr[$language]->$domains_arr[$domain]->field_seo->field_meta_description->value;
当属性不存在时,我该怎么做才能避免错误?例如,上面的 $lang_arr[$language](二级属性)不存在。我使用了 try-catch,效果很好,但我担心这可能会很耗时或在某些日志记录文本文件或其他地方累积错误。
【问题讨论】:
标签: php object properties try-catch