note 53735 deleted from function.return by tularis
| From: | tularis@php.net | Date: | Sun, 06 May 2007 15:26:58 +0000 |
| Subject: | note 53735 deleted from function.return by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126250@lists.php.net to get a copy of this message | ||
Note Submitter: PackCat
----
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