For PHP debugging I made myself a pre() function like this:
function pre($data)
{
echo '<pre>'.print_r($data).'</pre>';
}
But it’s not displaying line breaks as it should. By example, I get all this on one line:
Template_model Object ( [id] => 1 [type] => 1 [shortname] => default [is_custom] => 0 [is_open] => 1 [options] => Array ( [id] => 1 [name] => background_color [value] => #6699CC [type] => 0 [campaign_id] => 8 [user_id] => 11 [template_id] => 1 ) )
Some parts should have linebreaks. What am I doing wrong?
This may sound newb, but I can’t understand what I do wrong when I’ve been using this for years.
Please not that I call my pre function before there is any other HTML displayed on the page.
Thanks!
You need to print the
prebeforeprint_r()asprint_r()handles its own output. Like this:I am however not sure if it would preserve line-breaks if you use the optional parameter (specifying that you want it to return the output instead). Let’s see what codepad has to say about it.