I’m using PHP 5.3.5 with Fast-CGI.
When I try to use gmdate() to set the initial value for a parameter, I get the following error:
Parse error: syntax error, unexpected ‘(‘, expecting ‘)’ in
MyClass.php on line 3
Here’s my code (line 3 is the line where myFunction is declared):
function myFunction($myDate = gmdate('Y-m-d')) {
// ...
}
Am I doing something wrong? Is this a bug? This also occurs if I do the same thing in a class function.
You can’t use a function as a default value for a function or method parameter.