June 2017
Intermediate to advanced
536 pages
9h 49m
English
The __isset() magic method is triggered by calling the isset() or empty() language constructs on inaccessible properties. The method accepts a single parameter, as per the following synopsis:
public bool __isset(string $name)
The $name argument is the name of the property being interacted with.
Let's take a look at the following object context example:
<?phpclass User{ private $data = [ 'name' => 'John', 'age' => 34, ]; public function __isset($name) { if (array_key_exists($name, $this->data)) { return true; } return false; }}$user = new User();var_dump(isset($user->name));
The User class defines a single protected array property called $data, and a magic __isset() method. The current method's inner workings simply do ...
Read now
Unlock full access