RE: [PHP] Function returns
| From: | Jonathan Wilkes | Date: | Mon, 12 Jan 2004 17:08:43 +0000 |
| Subject: | RE: [PHP] Function returns | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-174345@lists.php.net to get a copy of this message | ||
This is NOT good coding practice, ONLY return something from a function / method if it needs to,
otherwise you may get a performance hit.
regards
Jonathan
-----Original Message-----
From: Mark Cubitt [mailto:mark.cubitt@applegate.co.uk]
Sent: 12 January 2004 17:06
To: Shawn McKenzie; php-general@lists.php.net
Subject: RE: [PHP] Function returns
Shawn McKenzie wrote:
> 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???
I don't think there is a right or wrong way but personally I would do it
like this:
function do_it()
{
echo "hi" || return 0;
return 1;
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php