[英]Error trying to use static var inside an array in another class var
Besides of talk a lot of not useful things, there goes my code: 除了谈论很多没用的东西外,还有我的代码:
1 public static $_INT = 'INTEGER';
2 protected $_name = 'projetos';
3 protected $_primary = 'id';
4 protected $_fields = Array (
Array ('id', self::$_INT)
);
I'm having an error on line 4. 我在第4行遇到错误。
self::$_INT
is an expression, you cannot use an expression in the declaration of a property in a class, you can only use static values. self::$_INT
是一个表达式,你不能在类的属性声明中使用表达式,你只能使用静态值。
You will have to initialise $_fields
in the constructor if you want to do this. 如果要执行此操作,则必须在构造函数中初始化$_fields
。
Like 喜欢
class MyClass {
public static $_INT = 'INTEGER';
protected $_name = 'projetos';
protected $_primary = 'id';
protected $_fields;
public function __construct() {
$this->fields = Array (
Array ('id', self::$_INT)
);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.