Ver Mensaje Individual
  #2 (permalink)  
Antiguo 18/07/2012, 09:22
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Instaciar misma clase parametro diferente constructor

No, no se puede cambiar el constructor, tu clase debería más bien adaptarse, por ejemplo, tener un setter para el tipo y que lo puedas cambiar en cualquier momento, ej:
Código PHP:
Ver original
  1. class Demo
  2. {
  3.         private $type;
  4.  
  5.         public function __construct($type) {
  6.                $this->type = $type;
  7.         }
  8.  
  9.         public function setType($type) {
  10.                $this->type = $type;
  11.  
  12.                return $this;
  13.         }
  14.  
  15.         public function foo() {
  16.                 echo "Type es: {$this->type}";
  17.         }
  18. }
  19.  
  20. $d = new Demo('bar');
  21. $d->foo();
  22. $d->setType('baz');
  23. $d->foo();

Saludos.