News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Arnold Daniels' Blog:
A dark corner of PHP class casting
February 20, 2008 @ 12:08:00

In this blog entry Arnold Daniels talks about an issue he had in the past (needing a bit more functionality than the PEAR DB library could offer) and how he ended up solving it with what he calls a "dark corner" of PHP - class casting.

PHP has a function serialize, which can create a hash from any type of variable, scalars, array, but objects as well. Using the unserialize function, PHP can recreate the variable from the serialized hashed. If we look at how an object is serialized, we see only the properties and the class name are stored.

His method allows for class manipulation via changes to the serialized class information (like changing the value of the name parameter). His "casttoclass()" function makes changing this value simple.

0 comments voice your opinion now!
class casting serialize extend parent child


blog comments powered by Disqus

Similar Posts

Gonzalo Ayuso's Blog: Using node.js to store PHP sessions

Pádraic Brady's Blog: Redux: First Official Code!

Sitening.com: Getting Real With Databases in PHP

Felix Geisendorfer's Blog: Cake 1.2’s Set class eats nested arrays for breakfast!

Richard Heyes\' Blog: Updates to XML-RPC Library


Community Events





Don't see your event here?
Let us know!


update package voicesoftheelephpant version introduction language podcast framework laravel composer security opinion interview mvc series symfony community release tool library

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework