Re: Function returns
| From: | DvDmanDT | Date: | Sun, 11 Jan 2004 23:55:32 +0000 |
| Subject: | Re: Function returns | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-174264@lists.php.net to get a copy of this message | ||
Well... Definitly depends on what kind of function it is... However, instead
of echoing in a function, most ppl recommend echo do_it(), were do_it() is
function do_it()
{
return "Hi";
}
There are many builtin functions without a return value, simply cause they
don't need to, or there's no real logic in doing so... If you have a
function named something like output_fmt($str), which is only meant to
format a string and output it, there might not need a return value... Maybe
the output itself, but you get the idea.. Some things just doesn't make
sense to return... And some things might return to a parameter... Right now
I can't think of an example though..
--
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
"Shawn McKenzie" <nospam@mckenzies.net> skrev i meddelandet
news:20040111230122.46064.qmail@pb1.pair.com...
> Maybe a dumb question, but as good coding practice, should all functions
> return something even if they don't need to???
>
> Example:
>
> function do_it()
> {
> echo "hi";
> }
>
> --or--
>
> function do_it()
> {
> return echo "hi";
> }
>
> Also, if they do other things but really don't return anything, should
they
> return true maybe???
>
> Just curious!
> -Shawn