Re: functions, opinion...
| From: | DvDmanDT | Date: | Tue, 17 Jun 2003 02:30:30 +0000 |
| Subject: | Re: functions, opinion... | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-151770@lists.php.net to get a copy of this message | ||
Or you could just temporarily enable ob... That's what I do when I have a
function that needs to return lots of HTML containing many ' and "... I know
it's possible to use \ as well, but ob is somewhat easier then...
"John W. Holmes" <holmes072000@charter.net> skrev i meddelandet
news:3EEE76E1.3010805@charter.net...
> 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
>
>
>
>