我想知道在一个数组中声明我的成员变量是否是不好的惯例,我后来在其他地方使用它(在下面的代码中,我传入insertArray()函数)。这是我的代码:
class myClass{
private $ID;
private $name;
private $type;
private $catID;
private $isDefault;
private $isRequired;
function __construct($compID = 0, $catID = 0, $name = '', $type = '', $default = false, $required = false){
$myArray = array(
'name' => ($this->name = $name),
'type' => ($this->type = $type),
'catID' => ($this->catID = $catID),
'isDefault' => ($this->isDefault = $default),
'isRequired' => ($this->required = $required)
)
self::insertArray($myArray);
}
}
在$ myArray中定义我的成员变量是不是很糟糕?我非常肯定在php中,表单的语法($ this-> value = $ value)会在$ this-> value中存储$ value,然后只评估为($ this-> value)。
答案 0 :(得分:0)