Reputation: 4558
My development server runs my PHP web application smoothly on PHP 5.3.8.
However, when upgrading my PHP production server from PHP 5.2.6 to 5.3.8 I got several problems with this application (complaints about deprecated function ereg_replace
and missing date.timezone
settings) which forced me to order a rollback to 5.2.6.
How can the same PHP code work fine on one 5.3.8 server and not on another? What are common causes for this behavior? Any suggestions?
Upvotes: 1
Views: 1384
Reputation: 27313
PHP is an evolving language, same for Java or c#, so it means you have to check the documentation if some functions are not deprecated and update your code accordingly.
Also you have to make sure your PHP settings are the same on both servers.
If you check the ereg_replace
documentation there is this blurb:
Warning This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.
Upvotes: 1
Reputation: 20540
are you totally positive that your development server runs PHP 5.3.8?
All ereg_*
functions are deprecated in PHP 5.3.X, so your code should not run on PHP 5.3 without any warning. if so, that is weird because your development server should generate more warnings (e.g. E_ALL
) than your production server. Check your error reporting settings in php.ini
. (display_errors
, error_reporting
)
to make it fly, you should really search for any occurance of ereg_*
and replace these expressions with a preg_*
equivalent.
date.timezone can be set in your php.ini
. After that, i see less reason why your PHP 5.2.6 code should not run on 5.3.6.
Upvotes: 1
Reputation: 23244
Your error level settings are not the same on your machines.
FYI:
ereg_replace is deprecated and using it is highly discouraged
every call to a date/time function will generate a E_NOTICE if the timezone isn't valid, and/or a E_WARNING message if using the system settings or the TZ environment variable
Upvotes: 3
Reputation: 535
Please access php.ini (PHP configuration file) on both server. Find the line "; display_errors"
Please compare the following lines after that.
These are the options available for the three settings variable:
; display_errors
; Default Value: On
; Development Value: On
; Production Value: Off
; display_startup_errors
; Default Value: Off
; Development Value: On
; Production Value: Off
; error_reporting
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
Upvotes: 2