1
可能重复:
Initializing PHP class property declarations with simple expressions yields syntax errorPHP字符串连接
是否有可能实现PHP 5.2.17
以下?
$basePath = '/final';
class Foo {
public $data = $basePath . '/data';
}
可能重复:
Initializing PHP class property declarations with simple expressions yields syntax errorPHP字符串连接
是否有可能实现PHP 5.2.17
以下?
$basePath = '/final';
class Foo {
public $data = $basePath . '/data';
}
为属性的默认值必须是恒定在源,例如字符串和数组文字。没有表达式。
使用__construct()
方法更复杂。
没有。属性声明中没有表达式。使用le构造函数。 – mario 2011-12-25 21:25:09
@mario谢谢,还没有找到该帖子。 – 2011-12-25 21:35:29