Brushing up a little on some of the things available in PHP5. Here’s something that made me weep happy tears. Given the XML file:
<people> <person> <name>Daryl L. L. Houston></name> <coolness>100%></coolness> </person> <person> <name>Steve Urkel></name> <coolness>-100%></coolness> </person> </people>
And the code:
<?php $people = simplexml_load_file('test.xml'); foreach($people->person as $person){ print $person->name . ' (' . $person->coolness . ')' . "\n"; } ?>
You get the output:
Daryl L. L. Houston (100%) Steve Urkel (-100%)
No iterating over arrays, no finding the right PEAR class and making sure you’ve got the right versions of dependent PEAR classes installed. It Just Works™.
I’ve more or less avoided PHP5 to date, as much of the code I write wouldn’t benefit a great deal from many of the things I understand PHP5 to provide, but this alone makes it worth a second glance.