本文介紹了isset($var) 與 @$var的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
這是使用 PHP 錯誤抑制的好做法還是可接受的方法?
Is this an okay practice or an acceptable way to use PHP's error suppressing?
if (isset($_REQUEST['id']) && $_REQUEST['id'] == 6) {
echo 'hi';
}
if (@$_REQUEST['id'] == 6) {
echo 'hi';
}
我也是這么想的.代碼(和想法)來自朋友.
謝謝你證明我是對的.:)
I thought so too. The code (and idea) is from friend.
Thanks for proving me right. :)
推薦答案
使用錯誤抑制并不是一個很好的做法.使用 $_REQUEST 甚至都不是一個好習慣.只需使用 isset() 或 !empty() 或其他什么,不要偷懶.
It's not a really good practice to use error suppressing. It's even not a good practice to use $_REQUEST at all. Just use isset() or !empty() or whatever, don't be lazy.
還有一件事,在使用isset()時關閉括號是一個好習慣":)
And one more thing, it is a "good practice" to close parenthesis when using isset() :)
這篇關于isset($var) 與 @$var的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!