tags:

views:

79

answers:

2

Hi,

I've got a problem when I'm calling a static var from another class. I get this pretty syntax error where php is unexpected the '.'

Here is where I'm calling 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  A: 

You can't use expressions to initialize class fields.

Sam Dark
+5  A: 

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

They are defined by using one of the keywords public, protected, or private, followed by a normal variable declaration. This declaration may include an 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 run-time information in order to be evaluated.
Your string concatenations are not constant. The parser doesn't "understand" the . operator in the initialization part and therefore prints unexpected '.'

VolkerK
Thanks alot I am very new to OOP with PHP.
Jonathan