Volevo chiedervi qual'è il motivo percui si sostituiscono i metodi magici __get e __set invece di usare dei semplici get e set (senza il doppio underscore).
Codice PHP:
public function __get($k)
{
if(array_key_exists($k, $this->data))
return $this->data[$k];
return NULL;
}
public function __set($k, $v)
{
if(array_key_exists($k, static::$types))
{
$this->data[$k] = $v;
return 1;
}
return NULL;
}
Codice PHP:
public function get($k)
{
if(array_key_exists($k, $this->data))
return $this->data[$k];
return NULL;
}
public function set($k, $v)
{
if(array_key_exists($k, static::$types))
{
$this->data[$k] = $v;
return 1;
}
return NULL;
}