Skip to content

Instantly share code, notes, and snippets.

@TheDistantSea
TheDistantSea / access_property.php
Created December 14, 2015 16:14 — forked from lastguest/access_property.php
PHP - Read/Write public/protected/private object property
<?php
// Access a property with no restrictions
function stole($object,$property){
$dict = (array)$object;
$class = get_class($object);
return isset($dict[$property])?
$dict[$property]:(isset($dict["\0*\0$property"])?
$dict["\0*\0$property"]:(isset($dict["\0$class\0$property"])?
$dict["\0$class\0$property"]:null));