http://uk.php.net/manual/en/function.print-r.php
http://uk.php.net/manual/en/function.var-dump.php
http://uk.php.net/manual/en/function.var-export.php
http://uk.php.net/manual/en/function.debug-print-backtrace.php
http://uk.php.net/manual/en/function.debug-backtrace.php
http://uk.php.net/manual/en/function.var-dump.php
http://uk.php.net/manual/en/function.var-export.php
http://uk.php.net/manual/en/function.debug-print-backtrace.php
http://uk.php.net/manual/en/function.debug-backtrace.php
PHP Debugging
print_r
print_r can print a variable or objectfor example
<?php echo "<pre>" ; echo print_r ($_SERVER,true) ; echo "</pre>" ; ?>
prints
Array ( [HTTP_USER_AGENT] => Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.0.5) Gecko/20060731 Ubuntu/dapper-security Firefox/1.5.0.5 [HTTP_ACCEPT] => text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 [HTTP_ACCEPT_LANGUAGE] => en-gb,en;q=0.5 [HTTP_ACCEPT_ENCODING] => gzip,deflate [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 )
var_dump
var_dump can dump a variable or objectfor example
<?php echo "<pre>" ; echo var_dump ($_SERVER) ; echo "</pre>" ; ?>
dumps
array(33) {
["HTTP_USER_AGENT"]=>
string(105) "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8.0.5) Gecko/20060731 Ubuntu/dapper-security Firefox/1.5.0.5"
["HTTP_ACCEPT"]=>
string(99) "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
["HTTP_ACCEPT_LANGUAGE"]=>
string(14) "en-gb,en;q=0.5"
["HTTP_ACCEPT_ENCODING"]=>
string(12) "gzip,deflate"
["HTTP_ACCEPT_CHARSET"]=>
string(30) "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
}var_export
var_export can export a variable or object as a parsable stringfor example
<?php echo "<pre>" ; echo var_export ($_SERVER,true) ; echo "</pre>" ; ?>
or if you are outputting to logfile
$block=explode("\n",var_export($out,true)) ;
foreach ($block as $line) {
error_log($line . str_repeat(' ',20);
} which is really nice because it uses the php magic function
__set_state
array ( 'myitem' => myclass::__set_state(array( 'element_id' => 155947, 'error_code' => true, 'error_msg' => '', 'loaded' => true)
PhpError
REFERRERS
PhpFunctions