Blog Post RSS ?

Blogs » PHP » Note on XML_Serializer Article
 

Note on XML_Serializer Article

by Harry Fuecks

If you’re reading Instant XML with PHP and PEAR::XML_Serializer, there’s a small point I need to correct, related to unserializing XML into PHP objects. On page 3, about half way down, I wrote;

Like PHP’s unserialize() function, XML_Unserializer doesn’t provide a mechanism for calling class methods when unserializing objects; rather, it sets the properties of an object directly (so, be careful):

Since writing that, while trawling the source discovered that XML_Unserializer does provide a mechanism to use a method for setting object properties, by using an explicitly named method like “set“, where is the name of the object property.

In other words, when unserializing objects, if your PHP class contains “setter methods”, following this naming convention, XML_Unserializer will use those methods instead of setting the property directly.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Ping.fm
  • Twitthis

Related posts:

  1. Techy Treasures #3: When is a mouseout not a mouseout? I've had this little gadget in my toolbox for a...
  2. A Note on Google’s So-called Best Practices The advice for PHP developers in Google's recent "make the...
  3. How to Write a Cookie-less Session Library for JavaScript Craig provides the code for a stand-alone JavaScript session variable...
  4. Cross-browser JSON Serialization in JavaScript JSON serialization can be incredibly useful, but few browsers support...
  5. An Introduction to JavaScript for Acrobat I’m always interested to see how JavaScript works on non-browser...

This post has 2 responses so far

Sponsored Links

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.

Follow SitePoint on...