Ver Mensaje Individual
  #24 (permalink)  
Antiguo 09/02/2011, 20:52
Avatar de SergeMedina
SergeMedina
 
Fecha de Ingreso: septiembre-2007
Ubicación: Guadalajara, Jalisco
Mensajes: 459
Antigüedad: 16 años, 7 meses
Puntos: 20
Respuesta: __get Y __set Necesito una pequeña guia

Ejemplo del manual de Zend Framework y que aun utilizo en mis aplicaciones:
Código PHP:
Ver original
  1. /**
  2.      *
  3.      * @param string $name
  4.      * @param mixed $value
  5.      */
  6.     public function __set($name,$value)
  7.     {
  8.         $method = 'set' . $name;
  9.         if(strripos('mapper', $name) !== false || !method_exists($this, $method)){
  10.             throw new Exception('Invalid property');
  11.         }
  12.         $this->$method($value);
  13.     }
  14.  
  15.     /**
  16.      *
  17.      * @param string $name
  18.      * @return mixed
  19.      */
  20.     public function __get($name)
  21.     {
  22.         $method = 'get' . $name;
  23.         if(strripos('mapper', $name) !== false || !method_exists($this, $method)){
  24.             throw new Exception('Invalid property');
  25.         }
  26.         return $this->$method();
  27.     }
__________________
I see dead pixels