Ver Mensaje Individual
  #4 (permalink)  
Antiguo 13/08/2012, 19:15
Avatar de xalupeao
xalupeao
 
Fecha de Ingreso: mayo-2008
Ubicación: Santiago, Chile
Mensajes: 749
Antigüedad: 16 años
Puntos: 12
Respuesta: Clase por parametro

Me habia faltado instanciar la clase.
Código PHP:
Ver original
  1. <?php
  2. /**
  3. *
  4. */
  5. class Usuario
  6. {
  7.     private $nombre;
  8.     private $apellido;
  9.  
  10.     public function getNombre()
  11.     {
  12.         return $this->nombre;
  13.     }
  14.  
  15.     public function setNombre($nombre)
  16.     {
  17.         $this->nombre = $nombre;
  18.         return $this;
  19.     }
  20.  
  21.     public function getApellido()
  22.     {
  23.         return $this->apellido;
  24.     }
  25.  
  26.  
  27.     public function setApellido($apellido)
  28.     {
  29.         $this->apellido = $apellido;
  30.         return $this;
  31.     }
  32.    
  33.     function __construct()
  34.     {
  35.         # code...
  36.     }
  37. }
  38.  
  39. /**
  40. *
  41. */
  42. class Registro
  43. {
  44.    
  45.     function __construct(Usuario $user)
  46.     {
  47.         echo $user->getNombre().' '.$user->getApellido().' ha sido registrado';
  48.     }
  49. }
  50.  
  51. $user = new Usuario();
  52. $user->setNombre('test')->setApellido('user');
  53. $registro = new Registro($user);

¿esto si es posible guardolo en una colletion o un array?
__________________
Hosting en Chile en Silverhost - La solución en Hosting en Chile.