PHP: Hypertext Preprocessor has been involving in all of its dynamics in the recent years. In recent times it has involved included and engulfed many of the recent development and api that has been introduced to the computer world especially web developing.
Switching to higher version of PHP is always good but before proceeding the switch we recommend to test the code in the new version and be well satisfied on the code execution.
In this doc we will be taking an overlook on the changes and precaution one should take if your are switching from a lower PHP version to higher PHP version, as below :
=====
Migrating from PHP 5.5.x to PHP 5.6.x
Migrating from PHP 5.4.x to PHP 5.5.x
Migrating from PHP 5.3.x to PHP 5.4.x
Migrating from PHP 5.2.x to PHP 5.3.x
=====
- Migrating from PHP 5.5.x to PHP 5.6.x
PHP 5.6.X has been developed with the aim to be backward compatible to its predecessor PHP 5.5.X. Although there are some function whose return values are alternated and others which are deprecated or discontinued. The following list the removed entity or incompatible changes
- There are changes brought up in array key when defining an array as a property of a class via an array literal
- There are changes made to json_decode() function.
- Changed the behaviour of SSL/TLS from this version onwards stream wrappers verifies peer certificates and host names by default. There are several other changes made to the OpenSSL.
- GMP resources are modified as objects. The code would work fine except for the function is_resource().
- Functions under mcrypt categories now require valid keys and IVs.
- Functions always_populate_raw_post_data, $HTTP_RAW_POST_DATA, conv.input_encoding, iconv.output_encoding, iconv.internal_encoding, mbstring.http_input, mbstring.http_output, mbstring.internal_encoding and methods called from an incompatible context are now deprecated.
- There are changes made through the function crypt(), substr_compare(), unserialize(), mcrypt_create_iv(), stream_socket_enable_crypto(), pg_insert(), pg_select(), pg_update(), pg_delete(), pg_send_execute(), pg_send_prepare(), pg_send_query() and pg_send_query_params() and XMLReader
- Number of constraint in the cURL library has been removed
Apart from the above new version has implemented a great necessary changes to the OpenSSL containers and functions which was under different vulnerability attack in the times.
Thus we suggest a through check and testing if the site is using the OpenSSL modules in PHP.
- Migrating from PHP 5.4.x to PHP 5.5.x
PHP 5.5.X has been developed with the aim to be backward compatible to its predecessor PHP 5.4.X. Although there are some function whose return values are alternated and others which are deprecated or discontinued. The following list the removed entity or incompatible changes.
- Support for windows OS changed only version vista and its successors are supported.
- Support for non ASCII code base has changed. These code must be tested in greta extends before migration.
- Functions pack() and unpack() are now more perl compatible and has some changed in the behaviour Functions php_logo_guid(), php_egg_logo_guid(), php_real_logo_guid() and zend_logo_guid() are no longer supported.
- The function zend_execute() can no longer be overwritten and many changes have come through in execute_data and its related functions and methods.
- Functions ext/mysql, preg_replace(), mcrypt_cbc(), mcrypt_cfb(), mcrypt_ecb(), and mcrypt_ofb() are now deprecated.
- There are some changes in the php core functions such as set_error_handler(), set_exception_handler() and json_encode().
- There are some changes in Internationalization Functions such as MessageFormatter::format(),MessageFormatter::parse(),IntlDateFormatter::__construct(), datefmt_create(), IntlDateFormatter::getCalendar(), datefmt_get_calendar(), IntlDateFormatter::setCalendar(), datefmt_set_calendar(), IntlDateFormatter::format() and datefmt_format()
- Extension intl now requires ICU 4.0 or later.
Apart from the above there are some changes in the php internal functions which are not much of our concern.
- Migrating from PHP 5.3.x to PHP 5.4.x
PHP 5.4.X has been developed with the aim to be backward compatible to its predecessor PHP 5.3.X. Although there are some function whose return values are alternated and others which are deprecated or discontinued. The following list the removed entity or incompatible changes.
- Applications that rely on safe mode may need to be adjustment as safe mode is no longer supported.
- Magic quote functions such as magic_quotes_gpc(), get_magic_quotes_runtime() and set_magic_quotes_runtime() rises error as they are not supported anymore.
- The directives register_globals, register_long_arrays and mbstring.script_encoding have been removed from php.ini.
- Variable argument on break and continue statement are no longer accepted. As for the reason break 0 and continue 0 are no longer allowed.
- Time zone can no longer set using the TZ environment variable in date and time extension.
- Non-numeric string offsets now return false on isset() and true on empty(), and produce a E_WARNING if you try to use them. Offsets of types double, bool and null produce a E_NOTICE. Numeric strings still work as before.
- An E_NOTICE level error is generated when converting an array to a string but the result of the cast will still be the string “Array”.
- Hash algorithms Salsa10 and Salsa20 have been removed..
- The third parameter of ob_start() has changed from boolean erase to integer flags.
- The words trait callable and insteadof are now reserved as keywords.
- Functions define_syslog_variables(), import_request_variables(), session_is_registered(), session_register() and session_unregister(). The aliases mysqli_bind_param(), mysqli_bind_result(), mysqli_client_encoding(), mysqli_fetch(), mysqli_param_count(), mysqli_get_metadata(), mysqli_send_long_data(), mysqli::client_encoding() and mysqli_stmt::stmt(). have been removed from PHP
- Sqlite PECL extension has been removed.
- php.ini directive register_globals, register_long_arrays, magic_quotes_gpc, magic_quotes_runtime, magic_quotes_sybase, allow_call_time_pass_reference, define_syslog_variables, highlight.bg, session.bug_compat_42, session.bug_compat_warn, mbstring.script_encoding, y2k_compliance, safe_mode, safe_mode_gid, safe_mode_include_dir, safe_mode_exec_dir, safe_mode_allowed_env_vars, and safe_mode_protected_env_vars are removed.
There are many new features, function and method implemented in the new release. As for the migration they are not of much concern to us.
- Migrating from PHP 5.2.x to PHP 5.3.x
PHP 5.3.X has been developed with the aim to be backward compatible to its predecessor PHP 5.2.X. Although there are some function whose return values are alternated and others which are deprecated or discontinued. Let us start with backward incompatible changes.
Backward incompatible changes
- New internal parsing Api has been implemented which causes the function to return NULL if the parameter passed are incompatible. There are some exception which error as of previous.
- Realpath cache are now no longer cleared by the function clearstatcache()
- Relative paths such as__FILE__ . “/../x” do not work any more as the function realpath() is fully platform independent.
- Object passed as argument are no longer supported in sort functions such as natsort(), natcasesort(), usort(), uasort(), uksort(), array_flip(), and array_unique().
- Now the functions with by-reference parameters called by value produces a fatal error. An alter is need to assign the value to the variable before calling.
- There are few upgrades in the mysqlnd library. The new password format of 41-byte implemented in MySQL 4.1 is only accepted. The use of previous 16-byte of password emit error in mysql_connect() and other similar functions. Also mysqlnd library does not read mysql configuration files (my.cnf/my.ini) it should be loaded explicitly with themysqli_options() function.
- Magic method __toString() can no longer accept arguments and magic methods __get(), __set(), __isset(), __unset(), and __call() can no longer be static but must always be public. Magic method __call() is now invoked on access to private and protected methods.
- Functions func_get_arg(), func_get_args() and func_num_args() must be called within a function in the calling file and can no longer be called from the outermost scope of a file that has been included by calling include.
- Hashing algorithm s2k is longer supported in PHP 5.3.X. instead an emulation layer for the MHASH extension to wrap around the Hash extension have been added.
- Words goto and namespace are reserved as keywords.
Apart from the above mentioned points the php support for windows as also brought some changes. In short, older version of the windows are no longer supported prior to win XP SP3 and the binary are target for architecture i586 and above.
There are many deprecated functions and ini derivatives in the new release. Since they are only deprecated they won’t arise any complication, it only gives a warning. But we do recommend to change the code if any such warning is through. As such function may be removed in the future release.
There are many new features, function and method implemented in the new release. As for the migration they are not of much concern to us.
These would be a better look at the changes in the php version upgrade one should have while switching.
We wish a happy switching/upgrade.
If you require help, contact SupportPRO Server Admin