Lo sapevi che con PHP 5.4 puoi accedere praticamente a tutte le proprietà di un oggetto? No? Prova (ma prima ripassati le closures):
Avete notato che il livello di visibilità di $mambanero è private?
PHP:
class Icchisi {
private $mambanero = "x";
function drinGhede($intercetta) {
return function() use ($intercetta) {
return $this->$intercetta;
};
}
function dranGhede() {
return function($intercetta) {
return $this->$intercetta;
};
}
}
$obj = new Icchisi();
$daje = $obj->drinGhede('mambanero');
echo $daje();
$aridaje = $obj->dranGhede();
echo $aridaje('mambanero');
Ultima modifica: