Ver Mensaje Individual
  #15 (permalink)  
Antiguo 19/07/2009, 19:46
Avatar de Highlander
Highlander
 
Fecha de Ingreso: junio-2006
Ubicación: Concepción, Chile
Mensajes: 475
Antigüedad: 20 años, 4 meses
Puntos: 4
Respuesta: Return multiples valores

Este codigo en el caso del array $datos no me entrega el valor al hacer el echo, si lo cambio a $_datos funciona.

Gracias por la ayuda.

Código PHP:
<?php


class Ingrediente {

    private 
$datos = array(); //$_datos
    
    
public function __construct ($nombre, $fuente, $energia, $proteina, $grasa_total, $colesterol, $hidratos_carbono, $sodio) {
        
$this->_datos['nombre'] = $nombre;
        
$this->_datos['fuente'] = $fuente;
        
$this->_datos['energia'] = $energia;
        
$this->_datos['proteina'] = $proteina;
        
$this->_datos['grasa_total'] = $grasa_total;
        
$this->_datos['colesterol'] = $colesterol;
        
$this->_datos['hidratos_carbono'] = $hidratos_carbono;
        
$this->_datos['sodio'] = $sodio; 
        
    }
    
    public function 
__get($dato) {
        return 
$this->datos[$dato]; //  $_datos
    
}
    
}

class 
Azucar extends Ingrediente {
    
    }
$ingrediente = new Ingrediente('Azucar', 'USDA', '1', '2', '3' ,'4', '5', '6');

echo 
$ingrediente->fuente;  


?>
__________________
Ingeniero (E) en Computación e Informática
The last man alone with god.