Fixing Errors on Old Sites After Upgrading PHP Version to PHP5.4

PHP.ini Changes

All this changes should be added to your php.ini file – you must be sure php.ini are in effect and really can change your hosting account settings.


php.ini must be put in full into your site folder, but when you want just to add directives into it, use .user.ini available from php version 5.3

How to Check?

You may start from creating a php file with any name, and adding <? phpinfo(); ?> inside. Then change some parameter and check that it has been changed indeed.

 Includes Path Fix

This is very embarrassing problem. Old sites I was making with php include suggested by fellow programmer:

<? include ($DOCUMENT_ROOT."/inc/news_en.php"); ?>

In latest versions of PHP, I think from version 5.3 they don’t work anymore.  We must set DOCUMENT_ROOT this days.

I found a solution somewhere… Put 2 lines below into your php.ini file inside your /public_html main folder. Change path as needed, you will see your right path in errors, when they are happen 🙂

date.timezone = 'Asia/Jerusalem'
auto_prepend_file = "/home/YOUR-ACCOUNT-USERNAME/public_html/doc_root.php"

And create that linked file named doc_root.php with code below:


Now server will know where to start.

P.S. Timezone is needed for server to know your timezone, I had some errors with it when upgraded to php5.3 before.

Fix Encoding of Scripts from Accidental Changing

When your language is not set as default UTF-8 or plain English, but anything else, we may need to ensure it’s not switching suddenly on different POST, GET etc. actions.

If you have mbstring extension on server installed, this could really help, when your page is accidentally switching language, i.e. on form submission.

;; Set HTTP header charset
default_charset = windows-1255    

;; Set default language to Hebrew
mbstring.language = Hebrew

;; HTTP input encoding translation is enabled.
mbstring.encoding_translation = On

;; Set HTTP input encoding conversion to auto
mbstring.http_input   = auto 

;; Convert HTTP output to windows-1255
mbstring.http_output  = windows-1255    

;; Set internal encoding to windows-1255
mbstring.internal_encoding = windows-1255    

;; Do not print invalid characters
mbstring.substitute_character = none

More info on this features is here.

Preferred PHP.ini Settings for Prestashop 1.5-1.6

I found such settings are good to resolve Prestashop configuration needs with PHP5.4:

memory_limit = 128M

 WordPress Memory Limit in wp-config.php

And finally, there is a convenient way to change wordpress site memory limit from inside wp-config.php file. Just add into this file:

define( 'WP_MEMORY_LIMIT', '128M' );

To check that the setting is active, find a plugin to check it, by searching for “memory limit”, or if i.e. you have woocommerce plugin installed, you may see it in system report/settings. There are more plugins that provide such information, but you’re not going to see it in regular root <? phpinfo(); ?> report, if you put wordpress installation in a folder.

For busy websites with large posts use such settings to allow longer output. Experiment with this settings to by adding more, until you see your site loads faster 🙂


This settings also could be added into Joomla configuration file.

This entry was posted in Hosting Server and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published.