Why is this code giving me an error?
<?
class Events
{
public $year = date("Y")+1;
public function sql() {
$sql = "select * from eventDates where eventDate < '" . $this->year . "' order by id";
return $sql;
}
}
$c = new Events();
echo $c->sql();
?>
The above gives the error:
PHP Parse error: syntax error, unexpected '(', expecting ',' or ';' in test2.php on line 5
I need to dynamically generate $year. How do I do that within the class?