Home > Article > Backend Development > PHP display_errors
PHP display_errors have some function that is used to define the list of errors and warnings with appropriate and detailed information. PHP display_errors provide aid to developers concerning troubleshooting and debugging. Any application related to PHP gets halted and stopped due to some reason will include some set of errors or warning that needs to be displayed as part of PHP display_errors. There are different levels of errors involved as part of display_errors at the time of execution. PHP Display_error order mentioned in the document should always be in “ON” mode when present within the document.
Start Your Free Software Development Course
Web development, programming languages, Software testing & others
There is no proper syntax for PHP display_errors, but still, some set of lines of codes with a specific format needs to be included within the script at the time of execution of PHP code at the time of execution. The line of codes is represented as follows :
ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
where,
Here are the following examples mention below
This program demonstrates the inclusion of a set of code within the ini file, but it fails as the display error and display startup error does not include parse errors depicting the exact location of the failure within the file and the output as shown.
Code:
<!DOCTYPE html> <html> <body> <?php ini_set('display_errors', 1); ini_set('display_start_up_errors', 1); error_reporting(E_ALL); include("abcd.php"); ?> </body> </html>
Output:
Note: To get the above error displayed in the proper understandable and readable format, then it is very much needed to display errors, including parse errors for which it is needed to make a change in php.ini or pgp-fpm in apache tomcat, i.e. in the working folder of apache tomcat with the following command as part of the configuration file: display_errors = ON.
This program demonstrates other types of errors that can be displayed, not necessarily including the overall PHP display_error functions. But sometimes, these kinds of errors or warnings come up with the developers as execution is almost smooth and should get easily solved.
Code:
<!DOCTYPE html> <html> <body> <?php $z = "Representation_of_Notice_Error."; echo $z; echo $Notice; ?> </body> </html>
Output:
This program demonstrates that the display_error with ini() function is enabled and restarted, as shown in the output. This warning comes into the picture when the display_error is enabled and restarted in the apache tomcat working folder.
Code:
<!DOCTYPE html> <html> <body> <?php for($h_1 = 1; $h_1 <= 8 $h_1++) { echo $h_1; } ?> </body> </html>
Output:
PHP display_error is quite an appropriate functionality as part of PHP and provides aid to programmers by providing them with the ability and flexibility to troubleshoot and debug the application easily. It makes the time consumption of debugging and troubleshooting less. Overall, It is a very efficient approach to use display_errors in PHP to get detailed information for errors and warnings as it helps in many ways.
The above is the detailed content of PHP display_errors. For more information, please follow other related articles on the PHP Chinese website!