Getter
Reads data from inaccessible properties by using magic methods.
To make a protected
or private
property readable, provide a method named
_magicGet{Property}()
which handles the reading. 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_magicGetFooBar()
. This method is then called when$fooBar
is read in a context where it normally would not be accessible.
Tags
Table of Contents
Methods
- __get() : mixed
- Read data from an inaccessible property.
- __isset() : bool
- Check if an inaccessible property is set and not empty.
Methods
__get()
Read data from an inaccessible property.
public
__get(string $property) : mixed
Parameters
- $property : string
-
The class property to get
Tags
Return values
mixed —The class property's current value
__isset()
Check if an inaccessible property is set and not empty.
public
__isset(string $property) : bool
Parameters
- $property : string
-
The class property to check
Return values
bool —Whether the class property is set and not empty