|
Posted by Benjamin on 12/05/06 03:28
Adam Scheinberg wrote:
> 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.
You must be afraid to write anything in PHP; merely adding "<pre>" and
"</pre>" is hardly worth a millisecond. Besides you only use this when
you're developing, right?
>
> 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.
Those file functions are a different story. They can be used for
writing and reading to streams; that's something that can't be
accomplished with just file_put_contents(). The custom print_r()
function you speak of doesn't add much functionality. That's why we
have user functions.
>
> 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
Navigation:
[Reply to this message]
|