How do I track problems in my PHP website?
Article Number: 1744 | Rating: Unrated | Last Updated: Fri, Jan 21, 2011 12:00 AM
Because of security reasons we don’t display PHP errors to the visitor on our shared environments. Due to the structure of our environment it is not possible to log default PHP errors, as we are doing now for visitors and apache error logs.
We can always change your PHP settings (php.ini), but this is a billing service and it is not always the best solution during the development phase.
To solve the problem, a piece of PHP code may be added to your .PHP files causing the problems. In the code you can still choose to display an error page to the visitor or to log errors to a file, or you can opt for a combination.
In the example below, this is shown through an incorrect PHPinfo function; this can be applied to each .PHP file. Be sure to put it at the top of the page, after the "
undefined undefined undefined undefined
ini_set(’error_log’, dirname(__FILE__) . ’/error_log.txt’);
In this example no error page is displayed to the visitors (display_errors has value 0), but the errors are logged to a file (log_errors has value 1 and in the line below the log file is named error_log.txt in the current folder).