Possible Duplicate:
Initializing PHP class property declarations with simple expressions yields syntax error
Is it possible to create an associative array and parse instances of a custom class as values?
Something like:
private static $contentTypeList = array(
"News" => new ContentType("News", "news.php", "News"),
"Termine" => new ContentType("Termine", "termine.php", "Termine"),
"Zeitplan" => new ContentType("Zeitplan", "zeitplan.php", "Zeitplan"),
"Fotos" => new ContentType("Fotos", "fotos.php", "Fotos"),
"Anfahrt" => new ContentType("Anfahrt", "anfahrt.php", "Anfahrt"),
"Guestbook" => new ContentType("Guestbook", "guestbook.php", "Gästebuch")
);
Trying this I’m getting an error like “unexpected keyword NEW”.
Do I use the wrong syntax or is it just not possible?
This is possible, but not when declaring the property outside of a function body.
Add it into any function, for example: