Ver Mensaje Individual
  #4 (permalink)  
Antiguo 17/08/2009, 09:16
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años, 9 meses
Puntos: 2135
Respuesta: Migracion hacia __set() y __get()

Un ejemplo:
Código PHP:
Ver original
  1. class Foo {
  2.       private $_attributes = array();
  3.  
  4.       public function __construct() {}
  5.  
  6.       public function __set($sVariable, $sData) {
  7.               $this->_attributes[$sVariable] = $sData;
  8.       }
  9.  
  10.       public function __get($sVariable) {
  11.               return $this->_attributes[$sVariable];
  12.       }
  13.  
  14.       public function dumpAttributes() {
  15.               var_dump($this->_attributes);
  16.       }
  17. }
  18.  
  19. $bar = new Foo();
  20. $bar->foo = "baz";
  21. $bar->baz = "foo";
  22. $bar->anumber = 1;
  23.  
  24. $bar->dumpAttributes();

Saludos.