如何在我的开发服务器上启用通知 - 不工作
I'm referring to How to enable notices on my development server
I expect the following code shall give me some warning, when I execute it through, as my $a
is not explicitly declared as array
php a.php
<?php
ini_set('display_errors', 1);
error_reporting(E_NOTICE);
$a['key'] = 123;
echo $a['key'] . "
";
However, no warning message being printed. Is there anything I had missed?
The PHP I'm using is PHP 5.5.3. I'm not sure this matters?
我指的是如何在我的开发服务器上启用通知 p>
我希望以下代码能给我一些警告,当时 我执行它,因为我的 但是,不会打印任何警告消息。 有什么我错过了吗? p>
我使用的PHP是PHP 5.5.3。 我不确定这很重要吗? p>
div> $ a code>没有显式声明为数组 p>
php a.php code> p>
&lt;?php
ini_set('display_errors',1);
error_reporting(E_NOTICE);
$ a ['key'] = 123;
echo $ a [' 关键']。 “
” 个;
code> pre>
I expect the following code shall give me some warning, when I execute it through, as my $a is not explicitly declared as array
Wrong... by writing $a['key'] = 123;
you declare an array and set the key
key to the integer number 123. That's a valid PHP array initialization. (The PHP version does not matter in this case.)
To explicitely produce an error notice for testing purposes…
If you want to provoke an error notice for testing purposes, you could add this line:
count($ThisIsNotDefinedOnPurpose);
which will produce an error notice saying
Notice: Undefined variable: ThisIsNotDefinedOnPurpose in … on line …