mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Update concept-properties.md
This commit is contained in:
@ -77,8 +77,8 @@ $object->label = 'abc';
|
||||
将赋给成员变量而不是 setter `setLabel()` 方法。
|
||||
* 这类属性不支持可见性(访问限制)。定义属性的 getter 和 setter 方法是 public、protected 还是 private 对属性的可见性没有任何影响。
|
||||
* 这类属性的 getter 和 setter 方法只能定义为**非静态**的,若定义为静态方法(static)则不会以相同方式处理。
|
||||
* A normal call to `property_exists()` does not work to determine magic properties. You should call [[yii\base\BaseObject::canGetProperty()|canGetProperty()]]
|
||||
or [[yii\base\BaseObject::canSetProperty()|canSetProperty()]] respectively.
|
||||
* 对不确定有无魔术方法(getter setter)的属性正常调用 `property_exists()` 将不会生效。你应该分别调用 [[yii\base\BaseObject::canGetProperty()|canGetProperty()]]
|
||||
和 [[yii\base\BaseObject::canSetProperty()|canSetProperty()]] 。
|
||||
|
||||
回到开头提到的问题,与其处处要调用 `trim()` 函数,
|
||||
现在我们只需在 setter `setLabel()` 方法内调用一次。
|
||||
|
Reference in New Issue
Block a user