[英]Error trying to use static var inside an array in another class var
除了談論很多沒用的東西外,還有我的代碼:
1 public static $_INT = 'INTEGER';
2 protected $_name = 'projetos';
3 protected $_primary = 'id';
4 protected $_fields = Array (
Array ('id', self::$_INT)
);
我在第4行遇到錯誤。
self::$_INT
是一個表達式,你不能在類的屬性聲明中使用表達式,你只能使用靜態值。
如果要執行此操作,則必須在構造函數中初始化$_fields
。
喜歡
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.