开发者

Do not receive certain PHP error messages

I am running Apache/PHP locally, and do receive errors in many cases, like uninitialized variables - but I have noticed a few cases where I do not receive error messages and am wondering if this is normal OR if I am missing out on anything,

<?php

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

$1a = "Hello world!";
echo $1a;

?>

Also producing no error:

<?php

ini_set('display_errors', 'On'开发者_Python百科);
error_reporting(E_ALL);

function a()
{
 $b = 5;
 echo $b;
}}

a();

?>

Does this script product PHP errors as it should for you? If so, I am wondering why I receive none. This is not an error I am likely to make, but there have been other times where I receive a blank page like above, where I would like some sort of feedback.


Your calls to ini_set never get executed, because the error happens in the parsing phase (i.e. before anything gets executed). You need to set those configuration values earlier in .htaccess, httpd.conf or php.ini.


Open up php.ini, and CTRL-F for display_errors - is it set to on? When I installed php I used ini_set(); to try and see errors and it didn't work, but editing the php.ini file worked.

Edit: I looked at your phpinfo() output on the page you posted, and it's set to off. Turn it on if you can. If I recall correctly, you have to restart apache after you edit it.

Edit2: In your php.ini file, error_reporting should be set to E_ALL & ~E_NOTICE (default), E_ALL | E_STRICT (development), or E_ALL & ~E_DEPRECATED (production). Honestly, that's all gibberish to me - but if it helps, mine is set to E_ALL & ~E_DEPRECATED, and I recieved errors from your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜