note 34180 added to functions.returning-values
| From: | rusty at rack1 dot php dot net | Date: | Thu, 17 Jul 2003 19:48:48 +0000 |
| Subject: | note 34180 added to functions.returning-values | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-52292@lists.php.net to get a copy of this message | ||
Here's a sick idea. When a function returns no value, if you assign its return value to a
variable that variable will be unset. So instead of returning -1 on error just return with no
value.
For example,
function myfunc($myvar) {
if ($myvar == "abc")
return(1);
if ($myvar == "xyz")
return(2);
return;
}
$abc = myfunc("def");
if (isset($abc))
echo("a-ok");
else
echo("oops");
----
Manual Page -- http://www.php.net/manual/en/functions.returning-values.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34180
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34180&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34180&report=yes