<?php
class Cliente {
private $id;
private $nome;
public function __construct($id = 0, $nome = NULL){
$this->id = $id;
$this->nome = $nome;
}
public function getId(){
return $this->id;
}
public function getNome(){
return $this->nome;
}
public function setId($value){
$this->id = $value;
return $this;
}
public function setNome($value){
$this->nome = $value;
return $this;
}
public function __set ($name,$value){
$this->$name = $value;
}
public function __get ($name){
return $this->$name;
}
}
$cliente = new Cliente();
$cliente->setId(2)
->setNome("Fulano 2");
echo $cliente->id . " " . $cliente->nome;
PD9waHAKCWNsYXNzIENsaWVudGUgewoJCXByaXZhdGUgJGlkOwoJCXByaXZhdGUgJG5vbWU7CgkJcHVibGljIGZ1bmN0aW9uIF9fY29uc3RydWN0KCRpZCA9IDAsICRub21lID0gTlVMTCl7CgkJCSR0aGlzLT5pZCAgID0gJGlkOwoJCQkkdGhpcy0+bm9tZSA9ICRub21lOwoJCX0KCQlwdWJsaWMgZnVuY3Rpb24gZ2V0SWQoKXsKCQkJcmV0dXJuICR0aGlzLT5pZDsKCQl9CgkJcHVibGljIGZ1bmN0aW9uIGdldE5vbWUoKXsKCQkJcmV0dXJuICR0aGlzLT5ub21lOwoJCX0KCQlwdWJsaWMgZnVuY3Rpb24gc2V0SWQoJHZhbHVlKXsKCQkJJHRoaXMtPmlkID0gJHZhbHVlOwoJCQlyZXR1cm4gJHRoaXM7CgkJfQoJCXB1YmxpYyBmdW5jdGlvbiBzZXROb21lKCR2YWx1ZSl7CgkJCSR0aGlzLT5ub21lID0gJHZhbHVlOwoJCQlyZXR1cm4gJHRoaXM7CgkJfQoJCQoJCXB1YmxpYyBmdW5jdGlvbiBfX3NldCAoJG5hbWUsJHZhbHVlKXsKCQkJJHRoaXMtPiRuYW1lID0gJHZhbHVlOwoJCX0KCQlwdWJsaWMgZnVuY3Rpb24gX19nZXQgKCRuYW1lKXsKCQkJcmV0dXJuICR0aGlzLT4kbmFtZTsKCQl9Cgl9CgkKCQoJJGNsaWVudGUgPSBuZXcgQ2xpZW50ZSgpOwoJCgkkY2xpZW50ZS0+c2V0SWQoMikKCSAgICAgICAgLT5zZXROb21lKCJGdWxhbm8gMiIpOwoJCgllY2hvICRjbGllbnRlLT5pZCAuICIgIiAuICRjbGllbnRlLT5ub21lOw==