当前位置: 首页 > 知识库问答 >
问题:

分析错误:语法错误,意外的'.',应为'、'或‘;’[关闭]

鲁宏爽
2023-03-14

这东西让我很烦。我得到解析错误:语法错误,意外的'.',需要'、'或‘;’在这条线

public static $user_table = TABLE_PREFIX . 'users';

共有1个答案

广瑞
2023-03-14
public static $user_table;

// Initialize it in the constructor 
public function __construct() {
  self::$user_table = TABLE_PREFIX . 'users';
}

// If you only plan to use it in static context rather than instance context 
// (won't call a constructor) initialize it in a static function instead 
public static function init() {
  self::$user_table = TABLE_PREFIX . 'users';
}

PHP 5.6对表达式的支持有限:

在PHP 5.6和更高版本中,相同的规则适用于常量表达式:一些有限的表达式是可能的,只要它们可以在编译时计算。

 类似资料: