{"id":21585,"date":"2023-07-24T08:26:00","date_gmt":"2023-07-24T08:26:00","guid":{"rendered":"https:\/\/stackify.com\/?p=21585"},"modified":"2024-09-01T04:57:14","modified_gmt":"2024-09-01T04:57:14","slug":"display-php-errors","status":"publish","type":"post","link":"https:\/\/stackify.com\/display-php-errors\/","title":{"rendered":"How to Display All PHP Errors: A Detailed Guide"},"content":{"rendered":"\n<p>A PHP application might produce many different levels of warnings and errors during its execution. Seeing these errors is crucial for developers when troubleshooting a misbehaving application. However, many developers often encounter difficulties displaying errors in their PHP applications, leading to silent app failures.<\/p>\n\n\n\n<p>Understanding the importance of displaying errors in PHP can&#8217;t be overstated. Error messages provide vital information about issues that occur while running a <a href=\"https:\/\/stackify.com\/docker-for-php-a-start-to-finish-guide\/\">PHP<\/a> script. They inform developers about syntax errors, which are mistakes made while writing code. They also notify developers about missing semicolons, which are important punctuation marks in certain programming languages. Furthermore, they bring attention to more complex issues that need to be debugged. Identifying and fixing these problems becomes a complicated guessing game without visible errors.<\/p>\n\n\n\n<p>With the complexity of PHP web applications, there are multiple methods to display errors, each with advantages depending on your specific use case.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"200\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2024\/09\/Error-messages-provide-vital-information-about-issues-that-occur-while-running-a-PHP-script.png\" alt=\"Error messages provide vital information about issues that occur while running a PHP script.\" class=\"wp-image-44717\" srcset=\"https:\/\/stackify.com\/wp-content\/uploads\/2024\/09\/Error-messages-provide-vital-information-about-issues-that-occur-while-running-a-PHP-script.png 1000w, https:\/\/stackify.com\/wp-content\/uploads\/2024\/09\/Error-messages-provide-vital-information-about-issues-that-occur-while-running-a-PHP-script-300x60.webp 300w, https:\/\/stackify.com\/wp-content\/uploads\/2024\/09\/Error-messages-provide-vital-information-about-issues-that-occur-while-running-a-PHP-script-150x30.webp 150w, https:\/\/stackify.com\/wp-content\/uploads\/2024\/09\/Error-messages-provide-vital-information-about-issues-that-occur-while-running-a-PHP-script-768x154.webp 768w, https:\/\/stackify.com\/wp-content\/uploads\/2024\/09\/Error-messages-provide-vital-information-about-issues-that-occur-while-running-a-PHP-script-600x120.webp 600w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-four-different-ways-to-display-errors-in-php\">Four different ways to display errors in PHP<\/h2>\n\n\n\n<p>Before diving into the details of managing and logging errors in PHP, let&#8217;s outline the four main ways to display errors in PHP:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>error_reporting: <\/strong>This function allows developers to determine which errors PHP will suggest. It can be set to display all errors, warnings, and notices except for some exceptions like E_NOTICE and E_STRICT.<\/li>\n\n\n\n<li><strong>display_errors:<\/strong> This is a directive in the php.ini file that determines whether errors should be printed to the screen as part of the output or if they should be hidden.<\/li>\n\n\n\n<li><strong>log_errors: <\/strong>This directive tells PHP whether it should log errors. If set to &#8220;On&#8221;, it will log errors according to what is set in the error_log directive.<\/li>\n\n\n\n<li><strong>error_log string:<\/strong> This directive determines where the error message should be sent. It could be sent to the server&#8217;s error log, a TCP port, or a separate file specified in the directive.<\/li>\n<\/ol>\n\n\n\n<p>All methods are compatible with PHP 8.x. The following additions were made to support modern PHP versions<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>error_reporting(E_DEPRECATED)<\/strong>: In PHP 8.x, using <strong>error_reporting(E_ALL)<\/strong>&nbsp;now includes E_DEPRECATED errors, which warn about deprecated features that will be removed in future PHP versions. This is crucial for future-proofing your code.<\/li>\n\n\n\n<li><strong>display_errors = stderr<\/strong>: In PHP 8.x, you can now set <strong>display_errors<\/strong> to <strong>stderr<\/strong>, which will direct error output to the standard error stream rather than the browser, useful in CLI applications.<\/li>\n<\/ul>\n\n\n\n<p>If you are having problems with your PHP web application and need to display all the errors and warnings, you are in the right place. In this tutorial, we will explain all the different ways to enable PHP errors and warnings. We will also discuss how to write the errors to a log file and even collect them via the Retrace\u2019s <a href=\"https:\/\/stackify.com\/retrace-error-monitoring\/\" target=\"_blank\" rel=\"noreferrer noopener\">error tracking feature<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-quickly-show-all-php-errors\"><a id=\"post-21585-_44xiubc99p27\"><\/a>Quickly Show All PHP Errors<\/h2>\n\n\n\n<p>The quickest way to display all php errors and warnings is to add these lines to your PHP code file:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted prettyprint\">ini_set('display_errors', 1);\nini_set('display_startup_errors', 1);\nerror_reporting(E_ALL);\n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-what-do-these-lines-of-code-do-exactly\"><a id=\"post-21585-_dre05xw7jawb\"><\/a>What Do These Lines of Code Do Exactly?<\/h4>\n\n\n\n<p>The ini_set function will try to override the configuration found in your PHP ini file.<\/p>\n\n\n\n<p>The display_errors and display_startup_errors are just two of the available directives. The display_errors directive will determine if the errors will be displayed or hidden from the user. Usually, the dispay_errors directive should be turned off after development.<\/p>\n\n\n\n<p>The display_startup_errors, however, is a separate directive because the display_errors don\u2019t handle the errors that will be encountered during PHP\u2019s startup sequence. The list of directives that can be overridden by the ini_set function is found in the <a href=\"http:\/\/php.net\/manual\/en\/ini.list.php\" target=\"_blank\" rel=\"noopener noreferrer\">official documentation<\/a>.<\/p>\n\n\n\n<p>Unfortunately, <strong>these two directives won\u2019t be able to display parse errors<\/strong> such as missing semicolons or missing curly braces. In this case, the PHP ini configuration must be modified.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-configure-php-ini-to-display-all-errors\">Configure PHP.ini to display all errors<\/h3>\n\n\n\n<p>If adding some of the PHP code errors doesn\u2019t show in the browser during testing, then the PHP ini configuration has some additional directives to handle this.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">display_errors = on<\/pre>\n\n\n\n<p>The display_errors directive must be set to \u201con\u201d in the PHP ini file. This will display all the errors including syntax or parse errors that cannot be displayed by just calling the ini_set function in the PHP code. The PHP ini file can be found in the displayed output of phpinfo() function and is labeled loaded configuration file. This directive in the ini configuration must be set to off, if the web application is in production.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-display-php-errors-via-htaccess-configuration\">Display PHP errors via .htaccess configuration<\/h3>\n\n\n\n<p>Developers usually have access to the directory files. The directive for showing PHP errors can also be enabled or disabled using the .htaccess file located in the root or public directory of the project.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">php_flag display_startup_errors on\nphp_flag display_errors on<\/pre>\n\n\n\n<p>Similar to what will be added to the PHP code to show PHP errors, .htaccess also has directives for display_startup_errors and display_errors. The advantage of showing or disabling error messages in this manner is that development and production can have different .htaccess files, where the production suppresses the displaying of errors.<br>Depending on which files you have access to and how you do deployments and server configurations, you may want to configure display_errors in .htaccess or your PHP.ini file. Many hosting providers will not allow you to modify your PHP.ini file to enable display_errors.<br>In the .htaccess file, a custom error log can also be enabled as long as the log folder or the log file is writable by the web server. The log file can be a relative path to where the .htaccess is located, or it can be an absolute path such as \/var\/www\/html\/website\/public\/logs.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">php_value error_log logs\/all_errors.log<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-enable-detailed-warnings-and-notices\">Enable detailed warnings and notices<\/h3>\n\n\n\n<p>Sometimes, the warnings that seem not to affect the application at the start will cause some fatal errors in certain conditions. These warnings must be fixed because this means that the application won\u2019t run normally under certain scenarios. In case these warnings cause a lot of errors, then it would be more practical to hide the errors and just show what the warning messages are.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">error_reporting(E_WARNING);<\/pre>\n\n\n\n<p>For a developer, showing warnings and hiding errors is just as simple as adding a single line of code. To show warnings and notices, the parameter for the error reporting function will be \u201cE_WARNING | E_NOTICE\u201d. The error_reporting function can accept E_ERROR, E_WARNING, E_PARSE, and E_NOTICE parameters as bitwise operators. To report all errors except for notices, then the parameter is \u201cE_ALL &amp; ~E_NOTICE\u201d where E_ALL stands for all the possible parameters of the error_reporting function.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-in-depth-with-the-error-reporting-function\">In-depth with the error_reporting() function<\/h3>\n\n\n\n<p>The error reporting function is a built-in PHP function that allows developers to control which and how many errors will be shown in the application. Remember, the PHP ini configuration has an error_reporting directive that will be set by this function during runtime.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">error_reporting(0);<\/pre>\n\n\n\n<p>To remove all errors, warnings, parse messages, and notices, the parameter that should be passed to the error_reporting function is zero. It would be not practical to have this line of code in each of the PHP files. It would be better to turn off report messages in the PHP ini file or in the .htaccess.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">error_reporting(E_NOTICE);<\/pre>\n\n\n\n<p>PHP allows variables to be used even when not declared. This is not a standard practice because undeclared variables will cause issues for the application once it is used in loops and conditions. Sometimes, this also happens because the declared variable has a different spelling than the variable being used for conditions or loops. When E_NOTICE is passed in the error_reporting function, then these undeclared variables will be displayed in the web application.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">error_reporting(E_ALL &amp; ~E_NOTICE);<\/pre>\n\n\n\n<p>The error reporting function allows you to filter which errors can be shown. The \u201c~\u201d character means \u201cnot\u201d or \u201cno\u201d so the parameter ~E_NOTICE means not to show notices. Notice the \u201c&amp;\u201d and \u201c|\u201d characters in between the possible parameters. The \u201c&amp;\u201d character is for \u201ctrue for all\u201d, while the \u201c|\u201d character represents either one as long as it is true. These two characters have the same meaning in PHP conditions OR and AND.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">error_reporting(E_ALL);\nerror_reporting(-1);\nini_set('error_reporting', E_ALL);<\/pre>\n\n\n\n<p>These three lines of codes do exactly the same thing, it will show all PHP errors. The error_reporting(E_ALL) is the most widely used among developers to show error messages because it is more readable and understandable.<\/p>\n\n\n\n<p>Consider using E_ALL | E_DEPRECATED for compatibility with PHP 8.x.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-log-php-errors-to-a-file-using-the-error-log-function\">Log PHP errors to a file using the error_log() function<\/h3>\n\n\n\n<p>During production, error messages must not be shown to the end users, but this information must still be recorded for tracing purposes. The best way to record these error messages on a production web application is to store it in log files.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"200\" data-id=\"44718\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2024\/09\/The-best-way-to-record-these-error-messages-on-a-production-web-application-is-to-store-it-in-log-files.png\" alt=\"The best way to record these error messages on a production web application is to store it in log files.\" class=\"wp-image-44718\" srcset=\"https:\/\/stackify.com\/wp-content\/uploads\/2024\/09\/The-best-way-to-record-these-error-messages-on-a-production-web-application-is-to-store-it-in-log-files.png 1000w, https:\/\/stackify.com\/wp-content\/uploads\/2024\/09\/The-best-way-to-record-these-error-messages-on-a-production-web-application-is-to-store-it-in-log-files-300x60.webp 300w, https:\/\/stackify.com\/wp-content\/uploads\/2024\/09\/The-best-way-to-record-these-error-messages-on-a-production-web-application-is-to-store-it-in-log-files-150x30.webp 150w, https:\/\/stackify.com\/wp-content\/uploads\/2024\/09\/The-best-way-to-record-these-error-messages-on-a-production-web-application-is-to-store-it-in-log-files-768x154.webp 768w, https:\/\/stackify.com\/wp-content\/uploads\/2024\/09\/The-best-way-to-record-these-error-messages-on-a-production-web-application-is-to-store-it-in-log-files-600x120.webp 600w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n<\/figure>\n\n\n\n<p>One easy way to use log files is to use the error_log function, which accepts four parameters. The only required parameter is the first parameter, which contains the details about the error or what\u2019s to be logged. The type, destination, and header are all optional parameters for this function.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">error_log(\"There is something wrong!\", 0);<\/pre>\n\n\n\n<p>The type parameter, if not defined, will be 0 by default, which means this log information will be appended to whatever log file is defined in the web server.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">error_log(\"Email this error to someone!\", 1, \"someone@mydomain.com\");<\/pre>\n\n\n\n<p>Here, the type 1 parameter will email an error log specified in the third parameter. To make this feature work, the PHP ini must have a proper SMTP configuration to be able to send out emails. These SMTP ini directives include host, encryption type, username, password, and port. This kind of error reporting is advisable to logging or notifying errors that need to be fixed as soon as found.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">error_log(\"Write this error down to a file!\", 3, \"logs\/my-errors.log\");<\/pre>\n\n\n\n<p>To log messages in a separate file defined by the configuration of the web server, then type 3 must be used. The third parameter will serve as the location of the log file and must be writable by the web server. The location of the log file can be a relative path to where this code is called or an absolute path.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Handling PHP Errors in AJAX Calls<\/h3>\n\n\n\n<p>When working with PHP and AJAX calls, errors can sometimes be difficult to track as they don&#8217;t display in the browser directly. Instead, they are returned to the AJAX request. To capture and see these errors, there are a few approaches:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. Use <strong>console.log()<\/strong> in the AJAX error handler<\/h4>\n\n\n\n<p>In your JavaScript code, you can add an error handler to your AJAX call. Here\u2019s an example of how you can use <strong>console.log()<\/strong> to display any errors that occur during an AJAX request:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$.ajax({ \nurl: 'your-php-script.php', \nmethod: 'POST', \ndata: { key: 'value' }, \nsuccess: function(response) { \nconsole.log('Success:', response); \n}, \nerror: function(xhr, status, error) { \nconsole.log('AJAX Error:', xhr.responseText); \n} \n});<\/code><\/pre>\n\n\n\n<p>In this example, any PHP errors that occur will be displayed in the browser&#8217;s developer console via <strong>xhr.responseText.<\/strong> This will help you see and troubleshoot errors while working with AJAX calls.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. Return error responses from PHP<\/h4>\n\n\n\n<p>Another way to handle errors in AJAX is to explicitly return error messages from PHP. You can do this by catching exceptions or errors and returning them in a format that your JavaScript can handle, such as JSON:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>try { <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Your PHP code <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>} catch (Exception $e) { <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>echo json_encode(&#91;'error' => $e->getMessage()]); <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>http_response_code(500); <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>}<\/code><\/pre>\n\n\n\n<p>On the JavaScript side, you can check for these errors and handle them appropriately.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-log-php-errors-through-the-web-server-configuration\">Log PHP errors through the web server configuration<\/h3>\n\n\n\n<p>To avoid changing parameters in the .htaccess or adding some lines in the PHP code to show errors, then the best way to log errors is defining it in the web server configuration file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ErrorLog \"\/var\/log\/apache2\/my-website-error.log\"<\/pre>\n\n\n\n<p>For Apache, these files must be added to the virtual host of the specific website or application. This is usually located inside the sites-available folder for Ubuntu or httpd-vhosts file in Windows.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">error_log \/var\/log\/nginx\/my-website-error.log;<\/pre>\n\n\n\n<p>For nginx, similar to Apache, the directive is just called error_log. For both Apache and nginx web servers, the log files must be writable by the web server. Luckily, upon installation, the folders for the log files of these two web servers are already writable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Modern Methods for Handling PHP Errors<\/h2>\n\n\n\n<p>As PHP continues to evolve, newer methods and directives have been introduced to handle error reporting more efficiently in various environments, especially for development versus production settings. Below are some modern approaches and tools you might consider using:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Using ini_set() for More Granular Control<\/h3>\n\n\n\n<p>While <strong>ini_set()<\/strong> has been around for a while, modern PHP practices encourage its use for more granular control over error reporting. For instance, you can disable error display for production while logging all errors to a secure file location:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ini_set('display_errors', 'Off'); <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ini_set('log_errors', 'On'); <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ini_set('error_log', '\/path\/to\/secure\/error.log'); <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>error_reporting(E_ALL | E_STRICT);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Error Handling with Exceptions in PHP 8.x<\/h3>\n\n\n\n<p>In modern PHP, handling errors using exceptions is considered a best practice, especially for larger applications. PHP 8.x allows developers to handle most types of errors as exceptions, offering more control over how errors are managed:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>try { <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Code that may throw an error <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>} catch (Error $e) { <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>error_log($e->getMessage()); <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Handle the error, e.g., by showing a user-friendly message <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. Using error_log() for Remote Logging<\/h3>\n\n\n\n<p>PHP 8.x supports logging errors to remote servers, which is useful for centralized logging in distributed applications. This can be done via syslog or external logging services:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>error_log(\"Application error\", 0, \"syslog\"); \/\/ Logs to syslog <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>error_log(\"Application error\", 0, \"udp:\/\/logs.example.com:514\"); \/\/ Logs to a remote syslog server<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-automatically-collect-php-errors-with-retrace-apm\">Automatically collect PHP errors with Retrace APM<\/h3>\n\n\n\n<p><a href=\"https:\/\/stackify.com\/retrace\/\">Retrace<\/a> is an APM (Application Performance Management) tool offered by Stackify. But the tool goes beyond monitoring the performance of your application. It allows you to do <a href=\"https:\/\/stackify.com\/retrace-log-management\/\">centralize logging<\/a>, perform <a href=\"https:\/\/stackify.com\/retrace-code-profiling\/\">code profiling<\/a>, and stay on top of <a href=\"https:\/\/stackify.com\/retrace-app-metrics\/\">server and application metrics<\/a>.<\/p>\n\n\n\n<p>One of the great features of <a href=\"https:\/\/stackify.com\/retrace\/\" target=\"_blank\" rel=\"noreferrer noopener\">Retrace<\/a> is its ability to automatically collect all unhandled errors in your <a href=\"https:\/\/stackify.com\/retrace-apm-php\/\">PHP application<\/a>. Our PHP extension will catch the exception and forward them automatically to Retrace.<\/p>\n\n\n\n<p>With Retrace, all the errors are automatically logged and formatted so that it can be viewed easily. Retrace will not only show what errors have occurred but also analyzes where and what caused it. The time and number of occurrences are also shown in the logs so that it would be a lot easier to focus on which issue to prioritize.<br>To learn more about Retrace, please check out the <a href=\"https:\/\/stackify.com\/retrace-error-monitoring\/\" target=\"_blank\" rel=\"noreferrer noopener\">Retrace feature page on error tracking<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/stackify.com\/wp-content\/uploads\/2020\/03\/php-errors-2020-1024x344.png\" alt=\"show php errors\" class=\"wp-image-28268\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n\n\n\n<p>To further improve your PHP debugging process, it&#8217;s recommended to familiarize yourself with other built-in PHP functions. One such functions are debug_backtrace() and debug_print_backtrace(). These functions provide detailed information about the list of preceding function calls, which is invaluable when tracking a tricky bug.<\/p>\n\n\n\n<p>Lastly, always remember to turn off error displays in a production environment. While displaying and logging errors during the development and testing phases is essential, it can also be a security risk. This is to prevent exposing potentially sensitive information to end-users.<\/p>\n\n\n\n<p>In conclusion, error management in PHP is a crucial aspect of development. By understanding how to use error_reporting, display_errors, log_errors, and error_log string, you can streamline your debugging process. This will improve the overall quality of your PHP applications.<\/p>\n\n\n\n<p>For a more comprehensive approach to error tracking and application performance management, consider using tools like Retrace. Retrace can automatically collect all unhandled errors in your PHP application. This will help you focus on what matters &#8211; creating fantastic user applications.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Being able to see what went wrong is vital during troubleshooting. Learn how to enable show all PHP errors and warnings in your app.<\/p>\n","protected":false},"author":39,"featured_media":41769,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[7],"tags":[52,134,19,39],"class_list":["post-21585","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","tag-developer-tips","tag-error-handling","tag-errors","tag-php"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v25.6) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Display All PHP Errors: A Detailed Guide - Stackify<\/title>\n<meta name=\"description\" content=\"Being able to see what went wrong is vital during troubleshooting. Learn how to enable show all PHP errors and warnings in your app.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/stackify.com\/display-php-errors\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Display All PHP Errors: A Detailed Guide - Stackify\" \/>\n<meta property=\"og:description\" content=\"Being able to see what went wrong is vital during troubleshooting. Learn how to enable show all PHP errors and warnings in your app.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/stackify.com\/display-php-errors\/\" \/>\n<meta property=\"og:site_name\" content=\"Stackify\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Stackify\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-24T08:26:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-01T04:57:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/stackify.com\/wp-content\/uploads\/2023\/07\/Display-All-PHP-Errors-Basic-Advanced-Usage-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"640\" \/>\n\t<meta property=\"og:image:height\" content=\"360\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Juliet Mendez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@stackify\" \/>\n<meta name=\"twitter:site\" content=\"@stackify\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Juliet Mendez\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/stackify.com\/display-php-errors\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/stackify.com\/display-php-errors\/\"},\"author\":{\"name\":\"Juliet Mendez\",\"@id\":\"https:\/\/stackify.com\/#\/schema\/person\/b3b39ab658fc4593a581e9cbbb37d1fe\"},\"headline\":\"How to Display All PHP Errors: A Detailed Guide\",\"datePublished\":\"2023-07-24T08:26:00+00:00\",\"dateModified\":\"2024-09-01T04:57:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/stackify.com\/display-php-errors\/\"},\"wordCount\":2464,\"publisher\":{\"@id\":\"https:\/\/stackify.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/stackify.com\/display-php-errors\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/stackify.com\/wp-content\/uploads\/2023\/07\/Display-All-PHP-Errors-Basic-Advanced-Usage-1.png\",\"keywords\":[\"developer tips\",\"error handling\",\"errors\",\"PHP\"],\"articleSection\":[\"Developer Tips, Tricks &amp; Resources\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/stackify.com\/display-php-errors\/\",\"url\":\"https:\/\/stackify.com\/display-php-errors\/\",\"name\":\"How to Display All PHP Errors: A Detailed Guide - Stackify\",\"isPartOf\":{\"@id\":\"https:\/\/stackify.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/stackify.com\/display-php-errors\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/stackify.com\/display-php-errors\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/stackify.com\/wp-content\/uploads\/2023\/07\/Display-All-PHP-Errors-Basic-Advanced-Usage-1.png\",\"datePublished\":\"2023-07-24T08:26:00+00:00\",\"dateModified\":\"2024-09-01T04:57:14+00:00\",\"description\":\"Being able to see what went wrong is vital during troubleshooting. Learn how to enable show all PHP errors and warnings in your app.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/stackify.com\/display-php-errors\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/stackify.com\/display-php-errors\/#primaryimage\",\"url\":\"https:\/\/stackify.com\/wp-content\/uploads\/2023\/07\/Display-All-PHP-Errors-Basic-Advanced-Usage-1.png\",\"contentUrl\":\"https:\/\/stackify.com\/wp-content\/uploads\/2023\/07\/Display-All-PHP-Errors-Basic-Advanced-Usage-1.png\",\"width\":640,\"height\":360,\"caption\":\"Display All PHP Errors Basic & Advanced Usage\"},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/stackify.com\/#website\",\"url\":\"https:\/\/stackify.com\/\",\"name\":\"Stackify\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/stackify.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/stackify.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/stackify.com\/#organization\",\"name\":\"Stackify\",\"url\":\"https:\/\/stackify.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/stackify.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/stackify.com\/wp-content\/uploads\/2024\/05\/logo-1.png\",\"contentUrl\":\"https:\/\/stackify.com\/wp-content\/uploads\/2024\/05\/logo-1.png\",\"width\":1377,\"height\":430,\"caption\":\"Stackify\"},\"image\":{\"@id\":\"https:\/\/stackify.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/Stackify\/\",\"https:\/\/x.com\/stackify\",\"https:\/\/www.instagram.com\/stackify\/\",\"https:\/\/www.linkedin.com\/company\/2596184\",\"https:\/\/www.youtube.com\/stackify\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/stackify.com\/#\/schema\/person\/b3b39ab658fc4593a581e9cbbb37d1fe\",\"name\":\"Juliet Mendez\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/stackify.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4f9a8bb14708a86f6bd52bb3c0577c6c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4f9a8bb14708a86f6bd52bb3c0577c6c?s=96&d=mm&r=g\",\"caption\":\"Juliet Mendez\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Display All PHP Errors: A Detailed Guide - Stackify","description":"Being able to see what went wrong is vital during troubleshooting. Learn how to enable show all PHP errors and warnings in your app.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/stackify.com\/display-php-errors\/","og_locale":"en_US","og_type":"article","og_title":"How to Display All PHP Errors: A Detailed Guide - Stackify","og_description":"Being able to see what went wrong is vital during troubleshooting. Learn how to enable show all PHP errors and warnings in your app.","og_url":"https:\/\/stackify.com\/display-php-errors\/","og_site_name":"Stackify","article_publisher":"https:\/\/www.facebook.com\/Stackify\/","article_published_time":"2023-07-24T08:26:00+00:00","article_modified_time":"2024-09-01T04:57:14+00:00","og_image":[{"width":640,"height":360,"url":"https:\/\/stackify.com\/wp-content\/uploads\/2023\/07\/Display-All-PHP-Errors-Basic-Advanced-Usage-1.png","type":"image\/png"}],"author":"Juliet Mendez","twitter_card":"summary_large_image","twitter_creator":"@stackify","twitter_site":"@stackify","twitter_misc":{"Written by":"Juliet Mendez","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/stackify.com\/display-php-errors\/#article","isPartOf":{"@id":"https:\/\/stackify.com\/display-php-errors\/"},"author":{"name":"Juliet Mendez","@id":"https:\/\/stackify.com\/#\/schema\/person\/b3b39ab658fc4593a581e9cbbb37d1fe"},"headline":"How to Display All PHP Errors: A Detailed Guide","datePublished":"2023-07-24T08:26:00+00:00","dateModified":"2024-09-01T04:57:14+00:00","mainEntityOfPage":{"@id":"https:\/\/stackify.com\/display-php-errors\/"},"wordCount":2464,"publisher":{"@id":"https:\/\/stackify.com\/#organization"},"image":{"@id":"https:\/\/stackify.com\/display-php-errors\/#primaryimage"},"thumbnailUrl":"https:\/\/stackify.com\/wp-content\/uploads\/2023\/07\/Display-All-PHP-Errors-Basic-Advanced-Usage-1.png","keywords":["developer tips","error handling","errors","PHP"],"articleSection":["Developer Tips, Tricks &amp; Resources"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/stackify.com\/display-php-errors\/","url":"https:\/\/stackify.com\/display-php-errors\/","name":"How to Display All PHP Errors: A Detailed Guide - Stackify","isPartOf":{"@id":"https:\/\/stackify.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/stackify.com\/display-php-errors\/#primaryimage"},"image":{"@id":"https:\/\/stackify.com\/display-php-errors\/#primaryimage"},"thumbnailUrl":"https:\/\/stackify.com\/wp-content\/uploads\/2023\/07\/Display-All-PHP-Errors-Basic-Advanced-Usage-1.png","datePublished":"2023-07-24T08:26:00+00:00","dateModified":"2024-09-01T04:57:14+00:00","description":"Being able to see what went wrong is vital during troubleshooting. Learn how to enable show all PHP errors and warnings in your app.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/stackify.com\/display-php-errors\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/stackify.com\/display-php-errors\/#primaryimage","url":"https:\/\/stackify.com\/wp-content\/uploads\/2023\/07\/Display-All-PHP-Errors-Basic-Advanced-Usage-1.png","contentUrl":"https:\/\/stackify.com\/wp-content\/uploads\/2023\/07\/Display-All-PHP-Errors-Basic-Advanced-Usage-1.png","width":640,"height":360,"caption":"Display All PHP Errors Basic & Advanced Usage"},{"@type":"WebSite","@id":"https:\/\/stackify.com\/#website","url":"https:\/\/stackify.com\/","name":"Stackify","description":"","publisher":{"@id":"https:\/\/stackify.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/stackify.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/stackify.com\/#organization","name":"Stackify","url":"https:\/\/stackify.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/stackify.com\/#\/schema\/logo\/image\/","url":"https:\/\/stackify.com\/wp-content\/uploads\/2024\/05\/logo-1.png","contentUrl":"https:\/\/stackify.com\/wp-content\/uploads\/2024\/05\/logo-1.png","width":1377,"height":430,"caption":"Stackify"},"image":{"@id":"https:\/\/stackify.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Stackify\/","https:\/\/x.com\/stackify","https:\/\/www.instagram.com\/stackify\/","https:\/\/www.linkedin.com\/company\/2596184","https:\/\/www.youtube.com\/stackify"]},{"@type":"Person","@id":"https:\/\/stackify.com\/#\/schema\/person\/b3b39ab658fc4593a581e9cbbb37d1fe","name":"Juliet Mendez","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/stackify.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4f9a8bb14708a86f6bd52bb3c0577c6c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4f9a8bb14708a86f6bd52bb3c0577c6c?s=96&d=mm&r=g","caption":"Juliet Mendez"}}]}},"_links":{"self":[{"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/posts\/21585"}],"collection":[{"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/comments?post=21585"}],"version-history":[{"count":0,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/posts\/21585\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/media\/41769"}],"wp:attachment":[{"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/media?parent=21585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/categories?post=21585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stackify.com\/wp-json\/wp\/v2\/tags?post=21585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}