Does a PHP array need to be declared before use?

后端 未结 3 2009
闹比i
闹比i 2021-01-17 19:09

While writing a recent application I accidentally started filling an array before I had declared it.

error_reporting ( E_ALL);  
$array[\'value\'] = \'Test          


        
3条回答
  •  感情败类
    2021-01-17 20:01

    To expand on that, no you do not "have" to, but it can be beneficial to.

    Also if you have E_NOTICES turned OFF then you will not see errors from an non uninitialized variable. On production you should turn it off, but on development you should turn it ON. It'll allow you to find problems that you might not see.

提交回复
热议问题