In HTML, newlines are counted as spaces, and multiple consecutive spaces are displayed as one single space, unless the content is inside a <pre> element.
In plain old php, the way to properly display print_r (in HTML) is this: <?php echo '<pre>' . htmlentities(print_r($variable, true)) . '</ pre>'; ?> var_dump doesn't have a return parameter; you have to do: <?php ob_start(); var_dump($variable); $dump = ob_get_contents(); ob_end_clean(); echo '<pre>' . htmlentities($dump) . '</pre>'; ?> But in CakePHP, the best way is just to do <?php debug($variable); ?> Which will format the code inside a <pre> tag (with class 'cake- debug') and add the line it was called from. As an added bonus, it only displays if you're in debug mode - in production mode debug() calls are ignored. On Feb 7, 10:48 am, leo <[EMAIL PROTECTED]> wrote: > Does anybody know why my var_dump.s and print_r.s all display without > format? Could it be a browser config? > > It all just appears as one continuous string. This isn't just cake, > it's plain old PHP too. > > It's something I've been meaning to investigate for years, but never > got around to doing so. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
