Problem with php includes when upgrading from PHP4 to PHP5

A friend come client of mine had a problem today – he was getting errors with his website, but had done nothing to the site. Errors a bit like this:

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/user/public_html/page.php on line xx

Warning: include( [function.include]: failed to open stream: no suitable wrapper could be found in /home/user/public_html/page.php on line xx

Warning: include() [function.include]: Failed opening ‘’ for inclusion (include_path=’.:/usr/lib/php:/usr/local/lib/php’) in /home/user/public_html/page.php on line xx

I figured it must have been something the hosting company did… it turned out to be right – they had upgraded from PHP4 to PHP5 – which doesn’t allow remote file includes (in order to prevent cross site scripting). On further investigation (involving me having to remember the username/password combination!) I discovered that the site (which I didn’t build) wasn’t actually pulling in remote headers, but was using a full url string like:

< ?php include(""); ?>

So after a quick hunt around (my PHP isn’t great), I found this blog post which reminded me of the answer I already knew but lacked the confidence to believe. I changed line to say:

< ?php include("includes/head.php"); ?>

And that worked. All I needed to do was download the rest of the PHP files and ran a multiple file search and replace on all the php files – backup the old site and reupload the amended code.

All working again. I just thought I would share that.