Sunday, May 17, 2020
How to Turn on PHP Error Reporting
If you are running into a blank orà white page or some other PHP error, but you have no clue what is wrong, you should consider turning on PHP error reporting. Thisà gives you some indication of where or what the problem is, and it is a good first step to solving any PHP problem. You use the error_reporting function to turn on error reporting for a specific file that you want to receive errors on, or you can enable error reporting for all your files at your web server by editing the php.ini file. This saves you the agony of going over thousands of lines of code looking for an error. Error_reporting Function The error_reporting() functionà establishes the error reporting criteriaà at runtime. Because PHP has several levels of reportable errors, this function sets the desired level for the duration of your script. Include the function early in the script, usually immediately after the opening ?php. You have several choices, some of which are illustrated below: How to Displayà Errors Display_error determines whether errors are printed on the screen or hidden from the user. It is used in conjunction with the error_reporting function as shown in the example below: Changing the php.ini File at the Website To see all error reports for all your files, go to your web server and access the php.ini file for your website. Add the following option: The php.ini file is the default configuration file for running applications that use PHP. By placing this option in the php.ini file, you are requesting error messages for all your PHP scripts.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.