Ver Mensaje Individual
  #1 (permalink)  
Antiguo 30/07/2006, 17:41
exist
 
Fecha de Ingreso: julio-2006
Mensajes: 45
Antigüedad: 17 años, 10 meses
Puntos: 0
Problema con reference o ? - PHP 5.0

Intento hacer reference de un variable a un class, pero , cuando intenta cambiar contenido mediante el reference, no se cambia nada.
Código PHP:
<?php
class XML    {
    
    public 
$xmlLink;

        public function 
connectXML($file)    {
            if (
file_exists($file))    {
                
$this->xmlLink simplexml_load_file($file);
            }
            else 
                return -
1;
            return 
$this->xmlLink;
        }
        function 
un ()    {
            unset(
$this->xmlLink);
        }
}
class 
test extends XML {
    
    public 
$origin;
    
    public function 
connectXML($file)    {
            
$this->origin = &parent::connectXML($file);
            
parent::un();
            
    }

    function 
show()    {
        echo 
"<pre>";
        
print_r($this->origin);
        echo 
"</pre>";    
    }

}

    
$xml = new test();
    
$xml->connectXML("data.xml");
    
$xml->show();
?>

Última edición por exist; 30/07/2006 a las 17:47