Ver Mensaje Individual
  #199 (permalink)  
Antiguo 17/01/2011, 10:43
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: Juego: "¿Dónde está el error?"

bien por David, es tu turno.

Como offtopic aquí hay una implementación para poder heredar el patrón Singleton:
Código PHP:
Ver original
  1. <?php
  2. class A
  3. {
  4.     private static $_instance;
  5.  
  6.     public static function getInstance()
  7.     {
  8.         if (self::$_instance == null) {
  9.             self::$_instance = new static();
  10.         }
  11.        
  12.         return self::$_instance;
  13.     }
  14. }
  15.  
  16. class B extends A
  17. {
  18.     private $_bar = 'foo';
  19. }
  20.  
  21. $obj = B::getInstance();
  22. var_dump($obj);