Trending October 2023 # How Display_Errors Work In Php With Examples? # Suggested November 2023 # Top 18 Popular |

Trending October 2023 # How Display_Errors Work In Php With Examples? # Suggested November 2023 # Top 18 Popular

You are reading the article How Display_Errors Work In Php With Examples? updated in October 2023 on the website We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested November 2023 How Display_Errors Work In Php With Examples?

Introduction to PHP display_errors

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);


ini_set(): This is the function that mainly will try to override the configuration found initially in the ini file.

display_errors: It is one of the directives that will determine whether there is a need to determine the error or remain hidden from the end-user.

display_startup_errors: It is another directive that is also behaving similarly as display_errors with a difference in the fact that the display startup error will be responsible for fetching all the errors at the startup time the screen.

error_reporting(): Error reporting function acts like a filter which is mostly responsible for filtering out the errors necessary for display.

E-ALL: It is the most recommended directive by developers as it provides more understandable and readable formats to developers.

How display_errors work in PHP?

PHP has a good significance for display_errors as it gives the programmers the ability to troubleshoot and provide a proper readable and understandable format of code.

It lets programmers debug with the detailed set of information concerning errors and warnings it provides.

The easiest way to achieve the display of all kinds of errors in PHP is to include some set of statements or codes within the ini file at the time of execution and compilation.

It helps in achieving the detailed display of error while execution by including some lines of code within the ini file as mentioned in the syntax.

Each function with the arguments passed on to the function has its own significance.

Ini() function always try to override the current configuration present within the ini file of PHP, and two directives make use of the ini function religiously. Both the two directives have their own role.

Display error directive is used whenever the need to display the error is not mandatory, and at the time of development, the display_error directive should be kept off; otherwise, it will create a hurdle.

On the contrary, display_startup_error has a different significance in the sense it is used only when the code execution gets started with the startup sequence as the Display error directive never participates for the same. It always makes use of the ini function to provide total functionality.

Also, some more interesting characteristics are involved related to both the directives; that is, they won’t be able to display any kind of Parse errors. Suppose in case the programmers forget to put the semicolon or some misses to put the curly braces than in that case it will be a problem for programmers as mentioned with the reason.

Sometimes it happens that in the real-time environment or testing environment, it becomes difficult to test with the already mentioned directives; then, in that case, there is the usage of some additional directives that need to be made either on or off to handle the implementation of code with the browser.

A solution to the above scenario is to make the display_error directive as ON using the following command to be included in the ini file as display_error = on. Then restart the apache tomcat folder by restoring the ini file in a working folder of apache tomcat.

This way, the ini_set() function will incorporate all the major directives as parameters and pass them accordingly at the time of execution of code.


Here are the following examples mention below

Example #1

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.


<?php ini_set(‘display_errors’, 1); ini_set(‘display_start_up_errors’, 1); error_reporting(E_ALL); include(“abcd.php”);


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 chúng tôi 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.

Example #2

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.


<?php $z = “Representation_of_Notice_Error.”; echo $z; echo $Notice;


Example #3


<?php for($h_1 = 1; $h_1 <= 8 $h_1++) { echo $h_1; }



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.

Recommended Articles

This is a guide to PHP display_errors. Here we discuss the introduction, syntax, and working of display_errors in PHP along with different examples. You may also have a look at the following articles to learn more –

You're reading How Display_Errors Work In Php With Examples?

Update the detailed information about How Display_Errors Work In Php With Examples? on the website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!