I recently made the switch from PHP4 to PHP5. Let me know if you see any breakages. Lots of hoopla about PHP4 being EOL‘d in 2007, effectively forcing everyone (including hosts) to upgrade to PHP5.

Matt from WordPress disses the heavy-handed move to PHP5. I personally like PHP5 better than PHP4, though my site was using PHP4 for everything. I notice Matt says “there isn’t a released PHP app today that isn’t PHP 5-compatible”. But I don’t think this can be true, unless he means PHP apps that matter to him. They point to this page which describes the differences between PHP 4 and 5, but I think something huge is missing from this page: DOM manipulation. There is a potentially big change to web apps out there that use DOM XML.

The only thing I had to do when migrating was to change my DOM XML function calls to use DOM.

  • DOM XML will “never be released with PHP 5”.
  • DOM is a PHP5-only feature.

These changes affect every line of code that used a DOM XML function, but the changes are pretty trivial, especially if you already know the DOM. XSLT handling is also not backward/forward compatible, from what I understand.

But why does that PHP page neglect to mention this? This was pointed out in 2004 by Justin Gehring, but the page fails to have been updated as an official notice. Alexandre Alapetite has provided a module that, I think, eases this transition (Disclaimer: I have not used this module because I rewrote my PHP for PHP5).

In all likelihood, I am missing something obvious here – so please chime in and put me on the clue-train. Do people typically not manipulate the DOM in PHP?

§419 · January 16, 2008 · PHP, Software, Technology, Web · Tags: · [Print]

2 Comments to “The Whole PHP5 Migration Thing”

  1. They do mention it on the DOM XML page… which, although it isn’t the first place you look for it when your migrating, is probably the logical place to put it… It’s why I left that comment 4 years ago on the migration page…

    For what it’s worth, and from what I’ve found in personal usage, I’m much happier with the built in library than I ever was with DOM XML… I always remember there being nightmares when trying to get the stuff to compile… Especially with the XSL stuff.. (I still laugh at a day I had at work where I was “battling sablotron”)

    Manipulating the DOM (especially large dom objects) can be very slow, and very painful. It tends to be faster to do with with a string replace, or to just not do it at all. In fact, I’ve migrated most of my applications to the regular XML library because the only time I personally use XML is to read it in and take actions on certain items (normally in a linear fashion, like with RSS). That said, it’s a lot easier on memory (and speed) to use the XML library than the DOM library (and a lot easier to error handle).

    Ok, I’m down… I’m glad Google Alerts alerted me to the usage of my name… This looks like an interesting blog :-). Live bookmark here I come!

  2. Thanks, Justin. I started to suspect that I was maybe in the minority by using the DOM library in PHP. Anyway, it’s written and it works, so I won’t be touching it anytime soon for the few places I use it.