1/*
2The following function names are magical in PHP classes.
3You cannot have functions with these names in any of
4your classes unless you want the magic functionality
5associated with them.
6*/
7__construct(),
8__destruct(),
9__call(),
10__callStatic(),
11__get(),
12__set(),
13__isset(),
14__unset(),
15__sleep(),
16__wakeup(),
17__serialize(),
18__unserialize(),
19__toString(),
20__invoke(),
21__set_state(),
22__clone(),
23 __debugInfo()
1<?php
2
3class Person{
4 private $firstName;
5
6 public function __get($propertyName){
7 echo "attempted to read non-existing property: $propertyName
8";
9 }
10 public function __set($propertyNane, $propertyValue){
11 echo "attempted to write to non-existing property: $propertyNane
12";
13 }
14
15}
16
17$p = new Person();
18
19$p->firstName = 'Doe';
20echo $p->firstName;
21
22$p->lastName = 'John';
23echo $p->lastName;
24