note 53735 added to function.return
| From: | PackCat at osu1 dot php dot net | Date: | Sat, 11 Jun 2005 01:02:01 +0000 |
| Subject: | note 53735 added to function.return | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90248@lists.php.net to get a copy of this message | ||
If you return a value that has not been set, or has been unset, the function will return that status
instead. So,
<?php
$var1 = 1;
function unsetVar($var) {
unset($var);
return $var;
}
$var1 = unsetVar($var1); // this will unset $var1
?>
This is useful in situations where we want to conditionally proceed based on the output of a
function; for example,
if (isset($fileListAsArray = functionGettingFileList())) {
// our list exists, do whatever
} else . . . // report error
----
Manual Page -- http://www.php.net/manual/en/function.return.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53735
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53735&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53735&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53735&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53735&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53735&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53735&report=yes
Search -- http://master.php.net/manage/user-notes.php