However this approach requires PHP 5.3.
For PHP < 5.3 there's another subtle way of accessing private properties:
function getPrivateProperty($fixture, $propname) {
try {
$arr = (array)$fixture;
} catch (Exception $e) {
}
$class = get_class($fixture);
$privname = "\0$class\0$propname";
return $arr[$privname];
}
try {
$arr = (array)$fixture;
} catch (Exception $e) {
}
$class = get_class($fixture);
$privname = "\0$class\0$propname";
return $arr[$privname];
}
Usage is pretty straightforward, pass in the object and the property name as string. The property must be private and must be convertible to array.
This is a good article. Thanks for sharing
ReplyDeleteSRI ANNAPOORNESHAWARI ASTROLOGY CENTER.Best Astrologer In Missouri
Great post, thanks
ReplyDeleteSRIKRISHANA ASTROLOGY.Vashikaran Astrologer in Raichur
Very good article,Thank you
ReplyDeleteABHIRAM ASTROLOGY CENTER.Best indian Astrologer In lake-louise
Nice post.Keep sharing. Thanks for sharing.
ReplyDeleteDURGAANUGARHA ASTROLOGY.vashikaran Astrologer In davangere
it was great information and very useful
ReplyDeleteABHIRAM ASTROLOGY CENTER.Best Astrologer In grande-prairie