鍍金池/ 問(wèn)答/PHP  網(wǎng)絡(luò)安全/ php Notice 錯(cuò)誤能不能顯示我要顯示的字?

php Notice 錯(cuò)誤能不能顯示我要顯示的字?

Notice: Undefined property: stdClass::$payment in /Applications/xxx/xxx/xxx/xxx.php on line 48

我知道可以把它關(guān)掉
但我想讓先顯示我想顯示的字:例如N/A
因?yàn)閷?duì)方該欄位數(shù)據(jù)還沒有傳json過(guò)來(lái)(還沒做)
先假設(shè)空的話則先顯示N/A
等他對(duì)方補(bǔ)上數(shù)據(jù)再顯示他的數(shù)據(jù)

回答
編輯回答
神曲
if (isset($a->$b->c)) {
    ...
}
2017年3月3日 12:34
編輯回答
練命
$payment = isset($user['payment'])?$user['payment']:'N/A';
2017年4月4日 14:06
編輯回答
疚幼
  • 可捕獲的致命錯(cuò)誤。類似 E_ERROR,但可被用戶定義的處理程序捕獲。(參見 set_error_handler())
2017年11月1日 03:25