dougu2036 2013-12-28 22:33
浏览 37
已采纳

在PHP中抑制回声通知

I am trying to use echo $var; in my code but sometimes it doesn't exist, so I get a notice from PHP. I don't want to disable all notices from PHP. Is it possible to prevent notice for this statement only?

Note: I tried @echo $var; but it gives me another error. I also found an alternate echo (isset($var) ? $var: ''); but it is quite long and I don't want to type it everytime.

  • 写回答

2条回答 默认 最新

  • dsbqfrr098575666 2013-12-28 22:36
    关注

    You should be able to use either one of the following

    echo @$var;
    @print $var;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?