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.
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 | 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 | Alternative | Comments |
---|---|---|
mysql_list_dbs() |
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
The salt option for the password_hash() function has been deprecated in PHP7.0
Also ldap_sort()
is no more available in PHP7.0
The e pattern modifier has been deprecated for the mb_ereg_replace() and mb_eregi_replace() functions.
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()
.
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:
Other deprecated functions