【发布时间】:2010-12-29 20:40:56
【问题描述】:
当声明一个数组为类成员时,应该怎么做?
class Test1 {
private $paths = array();
public function __construct() {
// some code here
}
}
或
class Test2 {
private $paths;
public function __construct() {
$this->paths = array();
// some code here
}
}
就良好做法和性能而言,哪一个更好?你会推荐什么?
【问题讨论】:
标签: php class constructor initialization