Code : Tout sélectionner
class test {
public $toto;
public function __construct() {
$this->TotO = 0;
}
public function __call($method, $value) {
$cmd = strtolower(substr($method, 0, 3));
$prop = strtolower(substr($method, 3));
$props = array_keys(get_object_vars($this));
if($cmd == 'set') {
foreach($props as $test) {
if(strtolower($test) == $prop) {
$this->{$test} = $value[0];
break;
}
}
}
if($cmd == 'get') {
foreach($props as $test) {
if(strtolower($test) == $prop) {
return $this->{$test};
}
}
}
}
}
Code : Tout sélectionner
$test = new test;
$test->setTOTO(7);
echo $test->getToTo();