PHP Core
Nested ternary operators without explicit parentheses
Nested ternary operations must explicitly use parentheses
to dictate the order of the operations. Previously, when used
without parentheses, the left-associativity would not result
in the expected behaviour in most cases.
Parentheses are not required when nesting into the middle operand,
as this is always unambiguous and not affected by associativity:
Array and string offset access using curly braces
The array and string offset access syntax using curly braces is
deprecated. Use $var[$idx]
instead of
$var{$idx}
.
(real) cast and is_real function
The (real)
cast is deprecated,
use (float)
instead.
The is_real function is also deprecated,
use is_float instead.
Unbinding $this
when $this
is used
Unbinding $this
of a non-static closure
that uses $this
is deprecated.
parent
keyword without parent class
Using parent
inside a class without a parent
is deprecated, and will throw a compile-time error in the future.
Currently an error will only be generated if/when the parent is
accessed at run-time.
allow_url_include INI option
The allow_url_include
ini directive is deprecated. Enabling it will generate
a deprecation notice at startup.
Invalid characters in base conversion functions
Passing invalid characters to base_convert,
bindec, octdec and
hexdec will now generate a deprecation notice.
The result will still be computed as if the invalid characters did not exist.
Leading and trailing whitespace, as well as prefixes of type 0x (depending on base)
continue to be allowed.
Using array_key_exists on objects
Using array_key_exists on objects is deprecated.
Instead either isset or property_exists
should be used.
Magic quotes functions
The get_magic_quotes_gpc and get_magic_quotes_runtime
functions are deprecated. They always return false
.
hebrevc function
The hebrevc function is deprecated.
It can be replaced with nl2br(hebrev($str))
or,
preferably, the use of Unicode RTL support.
convert_cyr_string function
The convert_cyr_string function is deprecated.
It can be replaced by one of mb_convert_string,
iconv or UConverter.
ezmlm_hash function
The ezmlm_hash function is deprecated.
restore_include_path function
The restore_include_path function is deprecated.
It can be replaced by ini_restore('include_path')
.
Implode with historical parameter order
Passing parameters to implode in reverse order
is deprecated, use implode($glue, $parts)
instead of implode($parts, $glue)
.
Multibyte String
Passing a non-string pattern to mb_ereg_replace
is deprecated. Currently, non-string patterns are interpreted as
ASCII codepoints. In PHP 8, the pattern will be interpreted as a
string instead.
Passing the encoding as 3rd parameter to mb_strrpos
is deprecated. Instead pass a 0 offset, and encoding as 4th parameter.
Reflection
Calls to ReflectionType::__toString now generate
a deprecation notice. This method has been deprecated in favor of
ReflectionNamedType::getName in the documentation
since PHP 7.1, but did not throw a deprecation notice for technical reasons.
The export()
methods on all Reflection
classes are deprecated. Construct a Reflection object and
convert it to string instead: