HTTP
|
|
|
|
<? #---------
# validate argument using func_get_args and func_num_args functions
# yinshu 11/11/2002
#---------
function validate () {
$args=func_get_args();
for ($i=0;$i<func_num_args();$i++) {
if (strlen($args[$i])==0) {
// if ($foo) will be false if $foo=0;
// strlen will false when null
echo "<b> Not enough arguments!</b>";
// hide this echo if you don't want extra error message
return FALSE;
}
}
return TRUE; // all argument exist }
#---------
# usage example, don't copy/paste below
#---------
$one=1;
$two=2; $zero=0;
if (validate($one,$two,$zero))
echo "<p>all arguments exist";
else
echo "<p>missing some, or whatever..";
# if any of those arguments is null, validate will return false
if (validate($one,$two,$zero,$three))
echo "<p>all arguments exist";
else
echo "<p>missing some, or whatever.."; ?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|