Better PHP Logging

June 16, 2015

If you are doing any kind of PHP development you will no doubt need to log out some values. Unlike JavaScript, logging out to the browser developer tools isn’t possibly as PHP is a server side language.

Thankfully with a tiny bit of markup wrapping your var_dump or print_r statement you can easily read information about the variable.

<?php

echo "<pre>";
var_dump(\$your_variable);
echo "</pre>";

?>

Or

<?php

echo "<pre>";
print_r(\$your_variable);
echo "</pre>";

?>