Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 使用简单表达式初始化 PHP 类属性声明会产生语法错误
是否有可能实现以下目标PHP 5.2.17?
PHP 5.2.17
$basePath = '/final'; class Foo { public $data = $basePath . '/data'; }
属性的默认值在源中必须是常量,例如字符串和数组字面量。没有表情。
对于更复杂的事情,请使用该__construct()方法。
__construct()