Handling errors

error message

PHP errors fall intofour categories: parsing errors, notices about code bugs such as uninitializedvariables, warnings (aka non-fatal errors), and fatal errors. Normally, whenPHP encounters either a parsing, non-fatal or fatal error, it displays theerror and—if the error is fatal—also stops script processing at that point. Youcan alter this behavior with theerror_reportingvariable, which accepts a bitfield of error codes and only displays errorsmatching those codes.

 

error_reporting =  E_ALL
To turn off the display of errors—recommended in productioncode—set the display_errorsvariableto false, and instead write the messages to an error log with the log_errors variable.
Doing this is good for security too—by turning off errors,you hide system-specific information that unscrupulous users could use to tryand damage your site or application. You should instead write these errors to acustom log file or to the system logger, by setting the error_log variable to either a file name or the special value”syslog”. Remember to check these log files regularly to keep an eyeon what’s happening inside your application.
display_errors = Offlog_errors = Onerror_log = “error.log”
Come back Thursday (July 22) forthe second part of this tutorial. I’ll take you deeper into the php.ini file,showing you the settings to configure file uploads and form parsing, run PHP inrestricted mode for greater security, activate extensions, set resource limitsfor memory usage, and disable legacy features for better performance

 

Posted in PHP Error Message | Leave a comment