sorry for the noobish question. I'm new with PHP class programming and I can't figure out why this piece of code doesn't work:
class Job {
private $var1 = 'hi there';
private $var2 = date('Y/m/d');
public function foo() { /* some code */ }
}
$job = new Job();
I get parse error parse error, expecting
','' or ';''
generated by $var2
.
Looks like I can't initialize a variable inside a class from a PHP function.
How can I bypass this error?
Thank in advance.