Voire même, pour affiner et jouer un peu :
<?php
class test {
private $myVar;
private $myVeryPrivateVar;
private $aForbid = array ('myVeryPrivateVar', 'aForbid');
public function __construct () {
$this -> myVar = 'hidden';
}
public function myGet () {
$aReturn = array ();
$aProps = func_get_args ();
foreach ($aProps as $prop) {
if (isset ($this -> $prop) && !in_array ($prop, $this -> aForbid)) {
$aReturn[$prop] = $this -> $prop;
}
}
return $aReturn;
}
}
$obj = new test ();
print_r ($obj -> myGet ('myVar', 'myVeryPrivateVar'));
?>