Deprecated language features are those that have been retained temporarily for backward compatibility, but which will eventually be removed from the language. In effect, deprecation announces a grace period to allow the smooth transition from the old features to the new ones. In that period, no use of the deprecated features should be added to the code, and all existing uses should be gradually removed.
The following functions were deprecated in PHP 5:
| Deprecated | Use Instead |
|---|---|
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() (note that this is deprecated in PHP 5.5) |
eregi() |
preg_match() with 'i' modifier |
eregi_replace() |
preg_replace() with 'i' modifier |
set_magic_quotes_runtime() and its alias, magic_quotes_runtime() |
|
session_register() |
$_SESSION superglobal |
session_unregister() |
$_SESSION superglobal |
session_is_registered() |
$_SESSION superglobal |
set_socket_blocking() |
stream_set_blocking() |
split() |
preg_split() |
spliti() |
preg_split() with 'i' modifier |
sql_regcase() |
|
mysql_db_query() |
mysql_select_db() and mysql_query() |
mysql_escape_string() |
mysql_real_escape_string() |
| Passing locale category names as strings | Use the LC_* family of constants |
The following functions were deprecated in PHP 7:
| Deprecated | Use Instead |
|---|---|
__autoload() |
spl_autoload_register() |
create_function() |
anonymous function |
parse_str() without second argument |
parse_str() with second argument |
gmp_random() |
gmp_random_bits() or gmp_random_range() |
each() |
foreach |
assert() with string argument |
|
Defining case-insensitive constants by calling define() with true as third parameter |
define("myconst", $value) or define("myconst", $value, false) |
FILTER_FLAG_SCHEME_REQUIRED and FILTER_FLAG_HOST_REQUIRED flags |
FILTER_VALIDATE_URL flag |
fgetss() function, "string.strip_tags" stream filter name, SplFileObject::fgetss() method and
gzgetss() function |
|
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() |
Use the corresponding mb_ereg_*() variants instead |
string search functions with integer needle (stristr, strrchr, strstr, strripos,
stripos, strrpos, strpos, strchr) |
use a string needle instead |
image2wbmp() |
imagewbmp() |
Normalizer::NONE |
|
Defining an assert() function inside a namespace |
use the standard assert() function |