Two very useful PHP functions
| From: | Raymond Irving | Date: | Thu, 30 Apr 2009 02:32:46 +0000 |
| Subject: | Two very useful PHP functions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-292140@lists.php.net to get a copy of this message | ||
Hello,
Every so often I have to be using the isset() function to check if a variable exists. It would be
useful to have something like an ifset() function
Instead of doing this
$v = isset($input) ? $input : $default;
we can do this
$v = ifset($input,$default);
// returns $input if it exists otherwise it will return $default
We could also do the same for the empty() function. So instead of doing this
$v = empty($input) ? $default : $input;
we can do this
$v = ifempty($input,$default);
// returns $input if it is not empty otherwise it will return $default
What do you think? Can they make it into 5.3?
Best regards
__
Raymond Irving