class Object public function getClass return get_class this public fun

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class Object {
public function getClass(){
return get_class($this);
}
public function __get($name){
$getterMethod='get'.$name;
if(method_exists($this,$getterMethod)){
return $this->$getterMethod();
}elseif(property_exists($this,$name)){
$backtrace=debug_backtrace();
trigger_error(
sprintf('Cannot access protected property %s::$%s in <b>%s</b> on line <b>%s</b>',$this->getClass(),$name,$backtrace[0]['file'],$backtrace[0]['line'])
, E_USER_ERROR);
}else{
$backtrace=debug_backtrace();
trigger_error(
sprintf('<b>Notice</b>: Undefined property: %s::$%s in <b>%s</b> on line <b>%s</b>',$this->getClass(),$name,$backtrace[0]['file'],$backtrace[0]['line'])
, E_USER_ERROR);
}
return NULL;
}
public function __set($name,$value){
$setterMethod='set'.$name;
if(method_exists($this,$setterMethod)){
$this->$setterMethod($value);
}elseif(property_exists($this,$name)){
$backtrace=debug_backtrace();
trigger_error(
sprintf('Cannot access protected property %s::$%s in <b>%s</b> on line <b>%s</b>',$this->getClass(),$name,$backtrace[0]['file'],$backtrace[0]['line'])
, E_USER_ERROR);
}else{
$backtrace=debug_backtrace();
trigger_error(
sprintf('<b>Notice</b>: Undefined property: <b>%s</b>::$<b>%s</b> in <b>%s</b> on line <b>%s</b>',$this->getClass(),$name,$backtrace[0]['file'],$backtrace[0]['line'])
, E_USER_ERROR);
}
}
}