On Mon, 2003-06-16 at 23:20, Jason Wong wrote: > On Tuesday 17 June 2003 12:50, DvDmanDT wrote: > > I was replying to "If you don't do it this way, you'll > > find yourself re-writing a function sooner or later because you need it > > to return the data instead of displaying it."... Then you don't need to > > modify the function if you turn on ob, call function, then get contents, > > then clear ob... Ok, it's a rather bad way to do it, but it works for me... > > Even the php crew had to rewrite functions because it displayed data instead > of returning. Case in point: print_r() recently had a extra argument added to > specify whether the output was printed or returned.
I agree with your point, but the adding of the second argument was more of a convenience thing than an admission that printing when calling a print statement was bad behaviour. :) Besides, it's more consistent since the introduction of var_export() with its similar abilities. As to your actual point (no more hair splitting): I agree. If the function has something to say, it's better to store that somehow and then use it when you need it. You get to determine when (and if) it gets output, and how. As someone else noted, you will sometimes find it necessary to break this rule (quick debugging statements, or functions whose purpose is to actually output something), but in general I wouldn't expect to see any benefit to having your functions doing their own output--beyond the initial convenience. For one thing, it can make effective use of templates a bloody pain. Just some thoughts, Torben -- Torben Wilson <[EMAIL PROTECTED]> +1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com -----==== Boycott Starbucks! http://www.haidabuckscafe.com ====----- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php