echo ($name ?? "查無資料");
當變數不存在時,在舊的PHP5不會產生錯誤,但PHP8會顯示錯誤訊息
如:echo "數量=" . $articlefun[0];
在PHP5不會出現錯誤,在PHP8將會顯示錯誤
可以改成
1.
if (isset($articlefun[0]))
echo $articlefun[0];
else
echo "查無資料";
2.
echo ($articlefun[0] ?? "查無資料");