fork download
  1. <?php
  2. class Cliente {
  3. private $id;
  4. private $nome;
  5. public function __construct($id = 0, $nome = NULL){
  6. $this->id = $id;
  7. $this->nome = $nome;
  8. }
  9. public function getId(){
  10. return $this->id;
  11. }
  12. public function getNome(){
  13. return $this->nome;
  14. }
  15. public function setId($value){
  16. $this->id = $value;
  17. }
  18. public function setNome($value){
  19. $this->nome = $value;
  20. }
  21.  
  22. public function __set ($name,$value){
  23. $this->$name = $value;
  24. }
  25. public function __get ($name){
  26. return $this->$name;
  27. }
  28. }
  29.  
  30.  
  31. $cliente = new Cliente();
  32. $cliente->id = 1;
  33. $cliente->nome = "Fulano 1";
  34.  
  35. echo $cliente->getId() . " " . $cliente->getNome();
  36.  
  37. // your code goes here
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
1 Fulano 1