 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Arnold Daniels' Blog: A dark corner of PHP class casting
by Chris Cornutt 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.
voice your opinion now!
class casting serialize extend parent child
Pavel Shevaev's Blog: A reliable way to serialize/unserialize objects in PHP
by Chris Cornutt December 11, 2007 @ 12:09:00
Pavel Shevaev has posted his method (a reliable way) for serializing and unserializing objects in your applications:
An experienced PHP developer might be wondering why posting this topic in a blog if PHP already has universal and almost transparent tools for this job [...] The key statement here is "almost transparent" which means you have to include all class definitions before invoking unserialize or use some __autoload schema.
The whole problem is due to the fact a serialized object has no idea about its class definition except the class name(the reason behind that is absolutely valid). [...] That's why I decided to hack up, hopefully, a more universal solution to this problem
His method contains things inside of a "serialization container" that automagically includes everything needed before it gets serialized. His code for the method is included as well as some examples of its use.
voice your opinion now!
serialize unserialize object container method serialize unserialize object container method
Evert Pot's Blog: PHP serializer in userland code
by Chris Cornutt June 21, 2007 @ 09:43:00
In this new blog post today, Evert Pot shares some thoughts on a custom solution he was looking to create as an alternative for PHP's serialize function.
I wanted to build this as a helper class for a draft-PHP-RPC server. The reason I needed a custom one was because I wanted to make sure I would be able to spit out PHP4-compatible serialized data, and in the future, when its ported to PHP6, also PHP5-compatible data.
He came across several issues in the development process including the slowness of his method compared to serialize() and a lack of a way to tell if two variables reference the same data. If you'd like to check out what he has so far, he's 0 comments voice your opinion now!
serialize phprcp server data alternative serialize phprcp server data alternative
DevShed: Working with MySQL and Sessions to Serialize Objects in PHP (Part 3)
by Chris Cornutt June 20, 2006 @ 11:58:59
DevShed has posted the third and final part of their "Serializing Objects in PHP" series today with a focus on integrating all of their previous code with a MySQL database.
Provided that you've already grasped the key concepts about object serialization, in addition to implementing some advanced features, such as the ones I mentioned right at the beginning of this article, in this final installment of the series, I'll show you some examples of how to work with objects and sessions. I'll also show you how to use MySQL tables to keep your objects safe and healthy.
They briefly touch on the code from the previous part, showing how to automatically serialize the objects easily. With that in place, they illustrate how to expand upon it, to combine these objects with sessions to register/store/retrieve them. Finally, they cover taking these same objects and storing them to a database (MySQL), including an example of handling user information.
voice your opinion now!
objects serialize mysql database tutorial sessions objects serialize mysql database tutorial sessions
DevShed: Using the Sleep and Wakeup Functions to Serialize Objects in PHP (Part 2)
by Chris Cornutt June 13, 2006 @ 08:11:34
DevShed continues their "serializing objects" series today with part two of the series, highlighting the use of the sleep and wakeup functionality of PHP to help with the serialization.
After refreshing the concepts that I deployed in the first part of this series, it's time to focus on the topics that I'll cover in this article, so you'll know what to expect before you continue reading. In this second part, I'll explain how to use objects in conjunction with the "__sleep()" and "__wakeup() magic functions respectively, in order to get the most out of them.
They start with a look at defining self-saving objects with their ObjectSaver class developed earlier. Building on that reminder, they integrate the "__sleep()" and "__wakeup()" functionality to handle calls immediately before and immediately after the handling of the object. They then use this new functionality to create persistent objects, capable of maintaining values across page requests.
voice your opinion now!
php serialize object persist sleep wakeup save php serialize object persist sleep wakeup save
|
Community Events
Don't see your event here? Let us know!
|