|
Posted by Adam Scheinberg on 12/04/06 17:26
print_r ALREADY returns a formatted array. 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.
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.
file_put_contents() can be accomplished with three existing functions -
fopen(), fwrite(), and fclose(). All three are present in PHP > 5.
Same with file_get_contents before 4.3. So these are bloat, right?
You see? It's never bloat if it adds beneficial utility. The arugment
that something like this would add "bloat" is probably from someone who
is unconvinceable to begin with, because they are coming to the table
with baggage.
I can't think of why echo'ing the contents of print_r() without
formating would *ever* be a requirement, but I guess this group has
spoken.
A
On Dec 4, 9:55 am, Michael Fesser <neti...@gmx.de> wrote:
> .oO(Adam Scheinberg)
>
> >On Dec 3, 10:38 pm, "Benjamin" <musiccomposit...@gmail.com> wrote:
> >> This sort of function might be nice for you but things like this are
> >> really what user functions are for. If PHP kept adding new
> >> "personalized" functions to the source, PHP would become really bloated
> >> and bulky. If you really want that function, you could create your own
> >> extension in C.
>
> >Why is this "personalized?" What I said was I see it all over the
> >place.I don't, because such things should only be used while developing, not
> in productive code. Additionally printing it out as preformatted HTML
> might be the most common way, but not necessarily always the best.
>
> You're better off with writing your own function that does exactly what
> you want and need. Write it once, put it in an external file, include it
> and you can use it all the time. In my applications for example I use
> two of them:
>
> debugPrint() -> returns preformatted HTML
> debugLog() -> writes the output to a logfile
>
> I would never expect PHP to already ship with such functions included.
>
> >Chaging the behavior of an existing function does not "add
> >bloat" if it does what develpers intended it to do.Changing it the way you intended would be unnecessary bloat. Currently
> print_r() returns raw data, which is perfectly fine for all kinds of
> further processing. Changing it to already return a specific formatting
> like HTML doesn't really make sense and would limit its uses (IMHO).
>
> Micha
[Back to original message]
|