语法错误,意外的 '.',期待 ')' [英] syntax error, unexpected '.', expecting ')'

查看:30
本文介绍了语法错误,意外的 '.',期待 ')'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从另一个类调用静态变量时遇到问题.我得到这个漂亮的语法错误,其中 php 出乎意料的 '.'

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)
);

这是我来自另一个类的静态 var 声明:

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;

推荐答案

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

它们是通过使用关键字public、protected 或private 之一定义的,后跟一个普通的变量声明.这个声明可能包含一个初始化,但这个初始化必须是一个常量值——也就是说,它必须能够在编译时被评估,并且必须不依赖于运行时信息才能被评估.
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.

您的字符串连接不是恒定的.解析器不理解".operator 在初始化部分,因此打印 unexpected '.'

Your string concatenations are not constant. The parser doesn't "understand" the . operator in the initialization part and therefore prints unexpected '.'

这篇关于语法错误,意外的 '.',期待 ')'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆