by there · 15y ago · 0 comments
for dumping arrays and things, i use an error_log_r() which just does print_r to the error log:
function error_log_r($obj) {
ob_start();
print_r($obj);
$lines = explode("\n", ob_get_clean());
foreach ($lines as $line)
error_log($line);
} $lines = explode("\n", print_r($obj,1));
Or better yet if we're playing golf: array_map('error_log', explode("\n", print_r($obj, 1)));thanks, i've updated my local implementation.
Also, this would make it easier to use Xdebug or something like that as it wouldn't require that to be installed in a possibly production system.
Also, most beginners using PHP start off with some shared hosting somewhere and get the directory include stuff wrong and now have live bad code on the web. At my university that was a big issue, but it is the only way these beginners had to test their website.