Debugging

From Php

Jump to: navigation, search

Many hosting providers have error reporting switched off by default, and users cannot change the configuration. You can check the settings for your host using phpinfo() as follows.

<?php
phpinfo();
?>

In the case where error reporting isn't given automatically, accessing the PHP page in your browser displays a blank page. However, you can still debug the code and see what the syntax error is by creating a separate PHP file and including the code which is failing, as follows.

<?php
ini_set( 'error_reporting', E_ALL );
ini_set( 'display_errors',TRUE );
include "image.php";
?>

Note: The messages will be displayed back to the browser, so this method shouldn't be used for pages that the user will see.

Personal tools