Jump to content

[SOLVED] Error reporting in PHP 5.x


mnabialek

Recommended Posts

I have problem with PHP 5.x (at the moment 5.2) - I have no idea how to display all the errors in PHP 5.

 

The following code:

 

<?php
  error_reporting(E_ALL);
  echo "aaa"
  $i=1;
?>

 

causes that I see a blank page - no errors about lack of semicolon.

 

 

There are settings from my php.ini file:

 

error_reporting  =  E_ALL & E_NOTICE & E_STRICT
display_errors = On
display_startup_errors = On
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = On
;html_errors = Off
;docref_root = "/phpmanual/"
;docref_ext = .html
;error_prepend_string = "<font color=ff0000>"
;error_append_string = "</font>"
error_log = C:/Program Files/wamp52/logs/php_error.log
;error_log = syslog

 

Do you have any idea what is going on?

 

Link to comment
Share on other sites

if error_reporting is already set to E_ALL in the php.ini no need to reset the error_reporting back to E_ALL in your script.

 

Also E_ALL includes all error messages except E_STRICT so instead of setting error_reporting to this:

error_reporting  =  E_ALL & E_NOTICE & E_STRICT

Set it like this:

error_reporting  =  E_ALL & E_STRICT

 

Save the php.ini and restart the server. Confirm the changes have been made by running the phpinfo() function and checking the settings  under the PHP Core heading.

 

Also make sure PHP is using the php.ini you are editing too by looking at the line that starts with Configuration File (php.ini) Path. It should show the full path to the php.ini it is currently using. If its set to just C:/WINDOWS then PHP cannot find the php.ini and is using the default settings.

Link to comment
Share on other sites

Thanks a lot for your reply. But there are many other problem connected with error reporting...

 

1)If I have even E_ALL in PHP file it should display this error with semicolon, right?

 

2) I noticed some strange things.

 

If I have in php.ini

error_reporting  =  E_ALL & E_STRICT

phpinfo shows

error_reporting	0	0

 

But if I input in php.ini

error_reporting E_ALL

phpinfo shows

error_reporting	6143	6143

 

3) If I have in php.ini error_reporting E_ALL

 

for PHP file:

<?php 
  //phpinfo();
  echo "aaa"
  $i=1;
?>

I really see the problem:

 

Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in C:\Program Files\wamp52\www\test.php on line 4

 

4) If I have in php.ini error_reporting  =  E_ALL  & E_STRICT

I see blank page (connected to 2 - it seems there's problem with & ? ) - do you have any idea why?

 

5) Why when I have a file:

 

<?php 
  error_reporting(E_ALL);

  phpinfo();
  echo "aaa"
  $i=1;
?>

 

and error_reporting  =  E_ALL  & E_STRICT in php.ini

 

I see also blank page ?

 

Even if there's problem with & operator, error_reporting in PHP file override those in php.ini (right?)

 

If I have only

 

<?php 
  error_reporting(E_ALL);

  phpinfo();
  $i=1;
?>

and also error_reporting  =  E_ALL  & E_STRICT in php.ini

 

I see in phpinfo

 

error_reporting	6143	0

 

Do you have any idea what is going on ?

Link to comment
Share on other sites

Ok I have done some testing and it appears the & symbol has a special meaning or something. You should use the pipe character (|) instead. That worked for me. So do

error_reporting  =  E_ALL | E_STRICT

 

instead

 

Also 6143 is the numerical value of E_ALL constant. So when you set error_reporting to E_ALL | E_STRICT PHP will report the error reporting level set  as 8191 (6143 (E_ALL) + 2048 (E_STRICT)).

 

Read up on error_reporting here

Link to comment
Share on other sites

Thanks a lot. It really solved the problem.

 

But the strangest thing is that

 

error_reporting  =  E_ALL & E_NOTICE & E_STRICT

 

was the default in php.ini

 

and as one of examples there is:

 

; Examples:
;
;   - Show all errors, except for notices
;
;error_reporting = E_ALL & ~E_NOTICE

 

But now I know, I have to use | instead od & :)

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.