I am newbie on PHP. Here is my situation. I write my code in vim and put it under /var/www/ then I can use
localhost/*.php
include this both line in code to see what kind of error is.
<?php
ini_set("display_errors",1);
error_reporting(E_ALL);
//code goes here
?>
You can check the log file output by PHP. A good way to see your configuration is to use phpinfo().
Also you can set error_reporting() so you can see the error message instead of a white page.
PHP produces an error_log
file in its directory whenever a problem occurs, you can find debug information there.
Also, try using var_dump($someVarible)
. This will give you useful information about the current state of a variable - often better than echo
.
Use these two lines to debug (this will enable to find the errors on the line numbers):
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
In most cases, if you set you error_report
to -1 you'll be able to see all notices, warning and errors in your browser.
If on a localhost, I would suggest using firefox or chrome and installing firebug for mozilla, and chrome gets a default. Be sure that on a local host your settings are matched to the server you are uploading to as this can cause problems when going live.
Specifically most shared hosting has PHP on safe mode and output buffering off, so if you use it, use it by calling it by calling ob_start(); etc, otherwise you should have no problems, and learning to debug is part of the fun, helps you learn alot :)
As for php errors just re-edit your php.ini file, you can find al relevant information on http://php.net
Happy Coding