Rolf Brusletto wrote: >> Just kind of curious what people think. In your opinion, >> should a function avoid output? What I mean by that, is should a >> function on "do something" without having echo or printf commands in it? >> This is something I've been thinking about lately to improve my >> programming style. Opinions? >
My personal opinion, which shows in all my code writing is to never echo inside a function. always return the data whether it be string, array, or boolean... I've always left echoing up to the actual page showing the data. That way if you have two seperate pages that need to display the data differently, you can use the same function, and just format it as needed on the pages.
I'll second that; I do the same. 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.
-- ---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
PHP|Architect: A magazine for PHP Professionals – www.phparch.com
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php