deprecated-php-function

Convert or Migrate PHP5.3 code to PHP7.3

Last Updated:

Are you still using old PHP5.x code? It’s better to Migrate your code to the latest version before it is too late. As most of the share host are upgrading their php version to the latest one there is a chance your website or web app stop working as before.

If your code is written in PHP 5.5 or 5.6, then upgrading to PHP 7.x will be real easy. However, if you are using PHP 4, then there will be some syntax changes you need to know. Like, the constructor functions in PHP 4 are no longer supported in PHP7.

Why You Should Migrate?

  • PHP 7 offers a 100% improvement in performance speed over its previous PHP 5.6 version
  • PHP 7 also offers fast performance to the Drupal users with the additional benefit of not using a virtual machine to execute the PHP code.
  • In PHP 5.6, the bug which makes the switch statement to have multiple default classes is now fixed.

Before migration you should know which version of PHP you are using and what are the function deprecated after your development.

Here we will discuss all the deprecated functions and its alternative step by step from php5.3 to php7.3

Deprecated features in PHP 5.3

Deprecated Alternative Comments
call_user_method() call_user_func()
call_user_method_array() call_user_func_array()
define_syslog_variables()
dl()
ereg() preg_match()
ereg_replace() preg_replace()
eregi() preg_match()
eregi_replace() preg_replace()
mcrypt_generic_end()
magic_quotes_runtime()
session_register() $_SESSION
session_unregister() $_SESSION
session_is_registered() $_SESSION
set_socket_blocking() stream_set_blocking()
split() preg_split()
spliti() preg_split()
sql_regcase()
mysql_db_query() mysql_select_db() and mysql_query()
mysql_escape_string() mysql_real_escape_string()

Deprecated Features in PHP 5.4.x

Deprecated Alternative Comments
mysql_list_dbs()


Deprecated Features in PHP 5.5.x

The original MySQL extension is now deprecated, and will generate E_DEPRECATED errors when connecting to a database. So, use the MySQLi or PDO_MySQL extensions. Click here to read mysql deprecated erros.

Deprecated Alternative Comments
preg_replace() preg_replace_callback()
IntlDateFormatter:: setTimeZoneID() IntlDateFormatter:: setTimeZone()
datefmt_set_timezone_id() datefmt_set_timezone()

Other deprecated functions are

  • mcrypt_cbc()
  • mcrypt_cfb()
  • mcrypt_ecb()
  • mcrypt_ofb()

Deprecated features in PHP 5.6.x

  • iconv.input_encoding
  • iconv.output_encoding
  • iconv.internal_encoding
  • mbstring.http_input
  • mbstring.http_output
  • mbstring.internal_encoding

Deprecated features in PHP 7.0.x

The salt option for the password_hash() function has been deprecated in PHP7.0
Also ldap_sort() is no more available in PHP7.0


Deprecated features in PHP 7.1.x

The e pattern modifier has been deprecated for the mb_ereg_replace() and mb_eregi_replace() functions.


Deprecated features in PHP 7.2.x

The png2wbmp() and jpeg2wbmp() functions from the GD extension have now been deprecated and will be removed in the next major version of PHP.
each() is deprecated use foreach instead.
Using assert() with a string argument has now been deprecated in favour of using boolean expressions.
The read_exif_data() alias has been deprecated use exif_read_data() function.
gmp_random() function is deprecated, use gmp_random_bits() or gmp_random_range().



Deprecated features in PHP 7.3.x

Passing a non-string needle to string search functions is deprecated. In the future the needle will be interpreted as a string instead of an ASCII codepoint. Depending on the intended behavior, you should either explicitly cast the needle to string or perform an explicit call to chr(). The following functions are affected:

  • strpos()
  • strrpos()
  • stripos()
  • strripos()
  • strstr()
  • strchr()
  • strrchr()
  • stristr()

Other deprecated functions

  • image2wbmp()
  • fgetss()
  • string.strip_tags stream filter
  • gzgetss()
  • SplFileObject::fgetss()
  • mbregex_encoding()
  • mbereg()
  • mberegi()
  • mbereg_replace()
  • mberegi_replace()
  • mbsplit()
  • mbereg_match()
  • mbereg_search()
  • mbereg_search_pos()
  • mbereg_search_regs()
  • mbereg_search_init()
  • mbereg_search_getregs()
  • mbereg_search_getpos()
  • mbereg_search_setpos()


Other Related Posts

MySQL deprecated error
PHP Error Handling
Undefined index PHP error



Top