note 95557 modified in function.isset by danbrown
| From: | danbrown@php.net | Date: | Fri, 08 Jan 2010 22:25:24 +0000 |
| Subject: | note 95557 modified in function.isset by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164803@lists.php.net to get a copy of this message | ||
Here's a nice little function that I use everywhere that'll help with setting alternate
values so you don't have a bunch of situations like:
<?php
if(isset($a))
{
$b = $a;
}
else
{
$b = "default";
}
function isset_or(&$check, $alternate = NULL)
{
return (isset($check)) ? $check : $alternate;
}
// Example usage:
$first_name = isset_or($_POST['first_name'], "Empty");
$total = isset_or($row['total'], 0);
?>
--was--
Here's a nice little function that I use everywhere that'll help with setting alternate
values so you don't have a bunch of situations like:
<?php
if(isset($a))
{
$b = $a;
}
else
{
$b = "default";
}
function isset_or(&$check, $alternate = NULL)
{
return (isset($check)) ? $check : $alternate;
}
?>
http://php.net/manual/en/function.isset.php