Private variables can be set thusly:
function setVar($obj, $var, $val)
{
$reflection = new ReflectionClass(get_class($obj));
$prop = $reflection->getProperty($var);
$prop->setAccessible(true);
return $prop->setValue($obj, $val);
}
But that's not that helpful when you're dealing with a function like fclose()
.
Superficially it seems like something like this could work:
Private varaibles can be accessed thusly:
function &getVar($obj, $var)
{
$reflection = new ReflectionClass(get_class($obj));
$prop = $reflection->getProperty($var);
$prop->setAccessible(true);
return $prop->getValue($obj);
}
fclose(&$getVar($obj, 'fsock'));
But in my testing it doesn't seem to work.
Any ideas?
Aucun commentaire:
Enregistrer un commentaire