|
Posted by Michael Fesser on 12/04/06 17:43
..oO(Adam Scheinberg)
>print_r ALREADY returns a formatted array.
Correct, but it's plain text.
>If you snoop the source,
>you'll see it yourself. It just doesn't return it with the <pre> tags
>around it, which is TRIVIAL to add.
But not always wanted or necessary.
>Furthermore, including such code in all development is slow - in each
>successfive page load PHP will have to parse a function, rather than
>having it precompiled in, which is loads faster.
Don't tell me you're worried about a single function being loaded each
time! Including a single file with some useful helper functions doesn't
make much of a difference, in fact you won't be able to measure it.
There are much "better" ways to waste CPU time.
>I can't think of why echo'ing the contents of print_r() without
>formating would *ever* be a requirement, [...]
Usually you don't want a HTML output, when you're
* using PHP-CLI
* writing the output to a logfile
* sending just plain text with header('Content-Type: text/plain')
Just some examples.
Changing the default behaviour of print_r() would definitely be the
wrong way. Of course you're free to suggest an additional function or a
third parameter to the PHP dev team, but I still consider it rather
pointless and too much effort.
Micha
Navigation:
[Reply to this message]
|