Posted by Toby A Inkster on 05/10/07 12:50
Iván Sánchez Ortega wrote:
> Or even with the more compact ternary-operator form:
> $search = isset($_GET['search']) ? $_GET['search'] : NULL ;
This is quite a common thing to do, so I recommend creating a function for
it:
function ifsetor ($a, $b)
{
if (isset($a)) return $a;
return $b;
}
$search = ifsetor($_GET['search'], NULL);
I keep meaning to write a function that does the same for N arguments
instead of 2.
--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python/Apache/Linux
[Back to original message]
|