Syntax error, unexpected '.', Pending ')'

I have a problem when I call static var from another class. I get this pretty syntax error where php is unexpected.

This is where I call it:

private $aLien = array( "menu1" => array("Accueil","statique/".Variable_init::$langue."/accueil.html",0,0), //This line "menu2" => array("Infos Pratiques","statique/".Variable_init::$langue."/info.html",0,0), "menu3" => array("Faire une réservation","statique/".Variable_init::$langue."/reserver.html",0,0), "menu4" => array("Pour Nous Joindre","statique/".Variable_init::$langue."/nousJoindre.html",0,0), "menu5" => array("Plan du site","statique/".Variable_init::$langue."/plansite.html",0,0) ); 

And here is my static var declaration from another class:

 class Variable_init implements iVariable_init{ public static $langue; public static $id_choix; public static $id_contenu; 
+4
source share
2 answers

http://docs.php.net/language.oop5.properties says:

They are defined using one of the keywords public, protected or private, followed by a normal variable declaration. This declaration may include initialization, but this initialization must be a constant value - that is, it must be able to be evaluated at compile time and must not depend on runtime information to be evaluated.
Your string concatenations are not permanent. The parser does not "understand . " operator in the initialization part and therefore prints unexpected '.'
+10
source

You cannot use expressions to initialize class fields.

+7
source

Source: https://habr.com/ru/post/1304042/


All Articles