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.

This post has 2 responses so far

  1. Seems I should have written some docs on XML_Serializer :-)
    For the future, I plan on making this feature more flexible.

    Stephan

     
  2. Seems I should have written some docs on XML_Serializer

    Not to worry. Gives me something to do ;) Of course if you can train that dog of yours some more…

     

Sponsored Links

Leave a response

You are not logged in, log in with your SitePoint Forum username and password.

-OR- Post Anonymously

* Make sure any code samples are escaped (i.e. ‘<b>’ becomes ‘&lt;b&gt;’).

If not logged in, your comments will be placed in a moderation queue. This means your comment may not appear until one of our moderators approves it.

SitePoint Marketplace

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

New Release!

The Principles Of Successful Freelancing

Book Cover: The Principles of Successful Freelancing

Become a successful freelancer TODAY!

Find out how!