Re: Beginner Tutorials for using CLASSES in PHP4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2007-10-09 at 11:41 -0400, Christoph Boget wrote:
> >
> > Maybe next time you'll have a challenge for me ;) And don't whine about
> > how I achieved what I did.
> 
> 
> Brilliant!  I never would have thought of that. ;)

It gets easier... here's a quick toolset for completely violating PHP5
objects :)

function objectCast( &$object, $class )
{
    $newObject =
        'O:'.strlen( $class ).':"'.$class.'"'
       .substr( serialize( (object)(array)$object ), 14 );

    $newObject = unserialize( $newObject );

    $object = $newObject;
}
 
function arraySetPrivateField
( &$objectArray, $className, $fieldName, $value )
{
    $objectArray["\x00$className\x00$fieldName"] = $value;
}
 
 
echo "\n";

$sucker = new TryToViolateEncapsulation();
$sucker = (array)$sucker;

print_r( $sucker );

arraySetPrivateField( $sucker, 'TryToViolateEncapsulation', 'someInt',
501 );
objectCast( $sucker, 'TryToViolateEncapsulation' );

print_r( $sucker );


-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux