I use this function to print array values to the screen:
function PrintArray($array)
{
echo " <pre>";
print_r($array);
echo " </pre> ";
}
For instance, to gain access to posted data:
if ($submit)
{
if ($debug)
{
printarray($_POST);
}
}
The rest of your script data (that which isn't immediately shown through markup) will need to be echoed/printed to file in $debug conditional statements.
You should build your app to include debug statements wherever potential for trouble may be found. At the top of your page, declare $debug = true; (or set it to false when not in use).
edited:
BTW, in my environment the debug statements are turned off if the script is served from production (detected programmatically). They can only show in test, and when $debug is set to true. As a commenter writes below, you should not display (or allow through mistake) debug information to show in production/live applications.
It's better to write your debug info to a file residing below the web root.