After migrating my servers entirely over to PHP5, my SurfHandsFree site stopped working properly.  The problem was that it uses the domxml_open_file function which is a PHP4 function and isn’t supported in PHP5.

PHP5 instead uses the dom extension instead which has more features but isn’t backwards compatible with domxml.

Instead of changing all of my code to be compatible with PHP5 (which is perhaps a better solution), I found a module that basically implements all of the PHP4 domxml functions but using the new dom extension.

All you need to do is to put the provided file, domxml-php4-to-php5.php in the directory of the script (or any directory) and include it at the top of your code with:

<?php require_once(”domxml-php4-to-php5.php”); ?>

A big thanks to Alexandre Alapetite for writing this module!

Popularity: 35% [?]

18 Responses to “Migrating from PHP4 domxml to PHP5 dom”
  1. Lois says:

    What’s the big difference between the two?

  2. So it’s not REALLY a transfer to PHP5, just a rewrite… basically?

  3. I figure a dollar is worth a couple of backlinks from his blog. Consider it done Im in. I want to go on that Sky Dive with him!

  4. Thanks for it. I will surely migrate it.

  5. edwin says:

    Thanks for your great post. Really usefull but, yeah…my site just build with html because I can’t with other. But, sure thanks for your share.

  6. Skips says:

    I want to go on that Sky Dive with him!

  7. That’s my problem with the release of new versions, they usually make projects developed in the previous version malfunction as you find that there’s a number of functions that are cancelled, therefore not supported by the newly released version.

  8. out with the old and in with the new!

  9. Ya me too I want to go on that Sky Dive with him!

  10. I would also guess that we can expect hashing to continue to evolve as the new versions of various programs evolve.

    Though it’s a pain in the butt, it is probably a good idea to change this stuff as some hacker will always be trying to break the code.

  11. Kef says:

    Initially we was using the php5 similator, which worked well! But when we upgraded our servers, we had a few problems. But I suppose it’s innevitable… or as they say progress?

  12. quotes says:

    I will not migrate for this feature for sure. Thanks for warning

  13. quotes says:

    I will not migrate for over to PHP5 for sure. Thanks for warning

  14. Did you upgrade your database as well? I think we updated to the latest PostgreSQL and we experienced problems as well.

  15. Abdul says:

    I really encountered these problems when I was to swicth from ASP 3.0 (since I work on ASP), the database connectivity script needed to be changed!

  16. teraom says:

    The require once is a little used style of coding and most programmers avoid this, taking for granted – the code works with this release.
    It might be a good thing to deprecate function in php (like in java), which ll ensure backward compatibility

  17. joomlapanel says:

    Its working fine on my server, I was tried it. many thanks for your sharing
    really useful

  18. Thank you so much for guide us about the difference between PHP4 domxml and PHP5 dom. its really useful for us all.

  19.  
Leave a Reply