[How to] Get Joomla 1.0 to work well under PHP 5.3


In particular, you can find that the content area is blank, the contact us page is completely blank, and lots of error messages appearing on screen warning about PHP functions that are 'deprecated'. Whilst you'd be able to find fixes for some of these errors on various different sites, nobody seems to have a complete patch for getting Joomla 1.0 running on PHP 5.3. So we looked for one. 


Look for all the function calls to eregi, eregi_replace, split, and assigning new by reference (=& new). These seem to be the main culprits for generating 'deprecated' errors which may fill up the screen or cause your error log to grow enormous. Replaced these functions with PHP 5.3 equivalent code. To apply the patch, download the following file, unzip it on your computer, and upload to your Joomla 1.0.15 site (use entirely at your own risk, and make sure you back up your site first, just in case!):


This is of course released under the GPLv2 license. The patch only includes core Joomla files. You might have 3rd party extensions that also produce errors. In this case, here is a brief guide on how to fix eregi, eregi_replace, split, and =& new (again, use this information entirely at your own risk):

In the error message (either on screen or in your error log) it usually tells you which file and line number is causing a problem.

Assigning the return value of new by reference is deprecated

If you get this error, just look for "=& new" and remove the ampersand (so it just says "= new").

Function eregi() is deprecated

You can replace eregi with preg_match, however you have to add a delimiter and a directive. Typically you use a forward slash as the delimter, but if the contents of the pattern in the first parameter contains a forward slash you will have to choose a different character (eg. a hash # or a pipe | are common alternatives). At the end of the string, you repeat the delimter, followed by the letter 'i' (meaning case insensitive). For example, change this:

eregi('pattern', $string)

to this:

preg_match('/pattern/i', $string)

or if the pattern contains a forward slash already, you could use this instead:

preg_match('|pattern|i', $string)

Function eregi_replace() is deprecated

This is dealt with in the same way as eregi, above, but instead of using preg_match, you use preg_replace.

Function split() is deprecated

In most cases you can simply replace split with explode. If the first parameter is a regular expression, you have to use preg_split instead.


One more thing...

Do you have friends or a Facebook group who you think would find this useful? Share this with them and then let me know what they think.

Want to supercharge your website?

Our website loads FAST ... just 1.29 seconds. We're hosted on FAST InMotion VPS servers We want YOUR website to be fast too, so we've gotten you an exclusive deal - 47% OFF for DART Creations friends + FREE domain! Check it out NOW!