Ver Mensaje Individual
Antiguo 11-feb-2007, 00:42   #2 (permalink)
GatorV
$this->role('moderador');
GatorV es realmente agradableGatorV es realmente agradableGatorV es realmente agradableGatorV es realmente agradableGatorV es realmente agradableGatorV es realmente agradable
 
Avatar de GatorV
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ags/
Mensajes: 15.631
Re: Constructores PHP

PHP no soporta como Java multiples constructores, lo que puedes hacer es algo asi:
Código PHP:
include_once( 'class.MySQL.php' );

class 
Usuario {
       private 
$mysql;
       private 
$user;
       private 
$pass;

       public function 
__construct() {
               
$this->mysql = new mysql();
               
$args func_get_args();
               if( 
count$args ) == ) {
                     list( 
$user$pass ) = each$args );
                     
$this->user $user;
                     
$this->pass $pass;
               }
       }

GatorV está desconectado   Responder Citando