isset($var) vs. @$var

前端 未结 5 1127
逝去的感伤
逝去的感伤 2020-12-11 02:18

Is this an okay practice or an acceptable way to use PHP\'s error suppressing?

if (isset($_REQUEST[\'id\']) && $_REQUEST[\'id\'] == 6) {
  echo \'hi\         


        
5条回答
  •  北海茫月
    2020-12-11 02:50

    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.

    And one more thing, it is a "good practice" to close parenthesis when using isset() :)

提交回复
热议问题