Possible Duplicate:
Can I use a function to return a default param in php?
Using function result as a default argument in PHP function
I am trying to set default value for a function. I want the function $expires
default value to be time() + 604800
.
I am trying
public function set($name,$value,$expires = time()+604800) {
echo $expires;
return setcookie($name, $value, $expires);
}
But I get an error.
Parse error: syntax error, unexpected '(', expecting ')' in /var/www/running/8ima/lib/cookies.lib.php on line 38
How should I write it?
if (!$expires) { $expires = time() + 604800; }
do it ? – user625860