Category Archives: PHP

DomDocument::loadXml not throwing exceptions in PHP

For some reason, Zend have decided not to make PHP throw an exception when you try and load invalid XML into a DomDocument object. This includes XML with invalid characters e.g. &. This means wrapping a try/catch around anything does … Continue reading

Posted in PHP, Programming | Leave a comment

PHP aaaaarrrrrggggghhhhhh

Things I hate about PHP No. 512 (notwithstanding the fact that in comparison to many other things I like PHP): Inconsistency in parameter ordering Say I want to find a small thing in a big thing, like a piece of … Continue reading

Posted in PHP, Programming | Leave a comment

PHP 4 foreach as references

PHP 4 doesn’t seem to create references for objects in foreach loops. e.g. the following will not change the original objects: foreach($placeholder as $contentBlock) { $contentBlock->setPosition(1); } The value of the position property in the original object will remain unaffected. … Continue reading

Posted in PHP, Programming | 2 Comments

PHP 4 annoyances ( = rant)

After working with PHP 5 for quite some time now, I’ve had to go back to PHP 4 to develop a CMS for a client’s site where we don’t have much over the hosting environment. Going back to the old … Continue reading

Posted in PHP, Programming | 1 Comment

PHP 5 Static class variable inheritence

PHP 5 doesn’t seem to attempt to implement any kind of inheritance for properties within static classes. This can be mean having to duplicate code within static subclasses. As an example, we would like to have a parent class (this … Continue reading

Posted in PHP, Programming | Leave a comment

Using importNode and appendChild with PHP 5 DOM

importNode is one of the DOM functions in PHP 5 that I struggled with for a while. What I wanted to do was to take an XML node from one document and insert it into another, and somehow that wasn’t … Continue reading

Posted in PHP, Programming | 4 Comments

Using removeChild with the PHP 5 DOM

The documentation for PHP 5’s DOM functions isn’t at its most helpful yet, so I thought an example of how to use ‘removeChild’ wouldn’t go amiss. Assuming first that you have some DOMDocument XML in a variable called $xml, that … Continue reading

Posted in PHP, Programming | Leave a comment