Weak typing in PHP: why use isset at all?

前端 未结 9 845
孤街浪徒
孤街浪徒 2020-12-01 12:38

It seems like my code works to check for null if I do

if ($tx) 

or

if (isset($tx))

why would I do the se

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 13:12

    The first one only works depending on how your server is configured. On many production servers, it will break.

    Use isset() and be merry.

    Or, try your code with the following at the top of the PHP source and watch it break:

    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    

提交回复
热议问题