I wrote a short post a while back called Adventures in PHP Land that briefly documented my first PHP project, a web site for my employer Lucidus. Well, the site went live on the first domain over at lucidusonline.co.uk and looked good. No major hassles and everything displayed how I expected it to.
Then I uploaded the same site to the main Lucidus domain.
PHP parsing errors.
Ok, following the little panic I got down to diagnosing the problem. It was confusing to say the least as the same code was running on the other domain so how could this be throwing parsing errors. My mate, Google, came in to play and I searched for the error messages. Problem is, they didn’t make sense. I was getting syntax errors on the most simple of lines of code…
As a first resort, I replaced these with var statements:
/* private */ var $pageContent;
/* private */ var $fileNotFound;
/* private */ var $targetFile;
Not sure why, that seemed to work. I moved on to the next problem with my functions throwing syntax errors. Again, I removed the private attribute and those syntax errors disappeared.
However, I got some content – that felt like magic – as so much stuff does when you have no idea why its working. So I tested the site out and nothing beyond the home page was working. Damn.
Fortunately (or is that unfortunately) I had encapsulated the main logic for the page navigation in a single CommandHandler class so I only had one place to look. Unfortunately, all of the code looked fine and, anyway, it was working n the other domain. The only way it could be failing is if the class constructor wasn’t being called and I had coded an __construct() method that was, after all, working on the other domain.
I little more searching on Google finally gave me the answer. An obvious answer in hindsight. The main domain is running on a server shackled to PHP 4. PHP 4 does not understand public/private methods and variables and requires the constructor to have the same name as the class. It seems I had been backing the code out to PHP 4 without even realising it.
Once the changes were made, the primary domain was up and running and everything was working fine.
Quick chat with the ISP and an upgrade to PHP 5 was refused. Unbelievable, but they “cannot” upgrade our server though they can offer us a migration to another of their hosting companies (at our cost). So we remain PHP 4 on the main web site and all “product” development will happen on the backup domain in PHP 5.