Ver Mensaje Individual
  #11 (permalink)  
Antiguo 29/07/2008, 13:40
Avatar de Quest
Quest
 
Fecha de Ingreso: diciembre-2002
Ubicación: Santiago
Mensajes: 129
Antigüedad: 21 años, 5 meses
Puntos: 2
Respuesta: Properties en PHP

pero __get y __set es lo mismo que poner echo $objecto->hola y $objeto->hola = 'hello world' u.u

Ahora tengo esto.
Código PHP:
<?php
class EntityData {
    
    var 
$properties = array();
    
    function 
__call($method$arguments
    {
        
//if (preg_match_all('/get(.+)/', $method, $test))
        
if (substr($method03) == 'get')
        {
            
//$property = $test[1][0];
            
$property substr($method3strlen($method));
            if (isset(
$this->properties[$property]))
            {
                return 
$this->properties[$property];
            }
        }

        
//if (preg_match_all('/set(.+)/', $method, $test))
        
if (substr($method03) == 'set')
        {
            
//$property = $test[1][0];
            
$property substr($method3strlen($method));
            if (
is_array($arguments))
            {
                
$this->properties[$property] = $arguments[0];
            }
            else
            {
                
$this->properties[$property] = $arguments;
            }
        }
        return 
false;
    }
}
?>
Aun no me decido si ocupar expresiones regulares o no :D

Saludos y garcias!!!
__________________
http://victorsanmartin.com
Web Developer
http://www.guiasitios.cl