Solved: optional arguments
Posted: Thu Jun 16, 2005 7:19 am
I want to make some arguments of my function optional. Take this example, based on how I would do this in other scripting languages:
(noting that $doowop never takes a zero value
I have also tried "if($doowop == null)".
Both options work, but return the warning "Missing argument 1 for blah() in c:\program files\easyphp1-7\www\u2wiki\test.php on line 1"
What's the cleanest way of doing this, without lots of messy error handling?
Code: Select all
function blah($doowop)
{
if (!$doowop)
{
return 'false';
}
else
{
return $doowop;
}
}
print blah();I have also tried "if($doowop == null)".
Both options work, but return the warning "Missing argument 1 for blah() in c:\program files\easyphp1-7\www\u2wiki\test.php on line 1"
What's the cleanest way of doing this, without lots of messy error handling?