Setter
Writes data to inaccessible properties by using magic methods.
To make a protected
or private
property writable, provide a method named
_magicSet{Property}()
which handles the writing. Replace {Property}
in
the method's name with the name of the actual property (with an uppercase
first letter).
Example: If the property is named
$fooBar
, the "magic" method has to be_magicSetFooBar()
. This method is then called when$fooBar
is written to in a context where it normally would not be accessible.
Tags
Table of Contents
Methods
- __set() : void
- Write data to an inaccessible property.
- __unset() : void
- Unset an inaccessible property.
Methods
__set()
Write data to an inaccessible property.
public
__set(string $property, mixed $value) : void
Parameters
- $property : string
-
The class property to set
- $value : mixed
-
The new value of the property
Tags
__unset()
Unset an inaccessible property.
public
__unset(string $property) : void
Parameters
- $property : string
-
The class property to unset