Link to home
Start Free TrialLog in
Avatar of MOSTAGHASSI
MOSTAGHASSIFlag for United States of America

asked on

Some question about 'error_reporting(E_ALL)' in php

Hello;

I have few questions about error_reporting(E_ALL);:

1-Where we must put this php function in a script,at the starting of codes?

2-If i check my page without this function and see that there is no error,does it need to add?

3-If the page which has this function has error,does it return the error in the same page?

4-If i have several script php in a page does it need that i put it for each script?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MOSTAGHASSI

ASKER

Hi Ray,thanks for your answer i have these questions:

-The function  ini_set()  is in php.ini or we must add to our script on every page?Please send an example.

-On my linux sever i have a dir by name of log that every day create a new file regarding the warning and errors,so does this file report errors, automatically or it depend setting  the error_reporting(E_ALL) in our script or both?
PHP ini_set() is documented here:
http://php.net/manual/en/function.ini-set.php
http://php.net/manual/en/configuration.changes.php

Here is an example that reports all errors, and logs errors, and displays errors.
<?php // demo/find_error_log.php

error_reporting( E_ALL );
ini_set( 'display_errors', TRUE );
ini_set( 'log_errors',     TRUE );

Open in new window


I don't understand the dir by name of log part of the question, sorry.
Sorry that my question was not clear, it is:

-On my linux sever there is  a directory that its name is logs and every day create a new file regarding the warning and errors of php(by reading these files i have corrected my codes),so does this file report errors as automatically or it depend setting  the error_reporting(E_ALL) in our script ?My mean is this that linux report php errors and warning as defulat?
At this time i have only the error_reporting(E_ALL) in my pages,
If you're able to see the PHP errors in the daily file in logs directory it sounds to me like you're in great shape!

In my installation, when there is a PHP error, warning, or notice, the message is written into a file named error_log in the same directory with the script that triggered the error.  So I have to look in several places to find all of my error logs.  That's what the find_error_log.php script above is for.  You may not have to do that if your error logging is set up differently.

You can make a test at any time you want - just install this script and run it.  Then you can look at the error logs and see that the message is getting put into the right places for your needs.  The trigger_error() function does the same thing as any other PHP error.
<?php trigger_error('A deliberately triggered warning', E_USER_WARNING);

Open in new window