isset($var) vs. @$var

前端 未结 5 1128
逝去的感伤
逝去的感伤 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:38

    Suppressing the errors using @ only suppresses the display of the error, not the creation. So you get a small performance hit from the error if you don't check isset() first.

提交回复
热议问题