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.
<?php
1 ? 2 : 3 ? 4 : 5; // deprecated
(1 ? 2 : 3) ? 4 : 5; // ok
1 ? 2 : (3 ? 4 : 5); // ok
?>
Parentheses are not required when nesting into the middle operand, as this is always unambiguous and not affected by associativity:
1 ? 2 ? 3 : 4 : 5 // ok
The array and string offset access syntax using curly braces is
deprecated. Use $var[$idx]
instead of
$var{$idx}
.
The (real)
cast is deprecated,
use (float)
instead.
The is_real() function is also deprecated, use is_float() instead.
$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.
The allow_url_include ini directive is deprecated. Enabling it will generate a deprecation notice at startup.
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 is deprecated. Instead either isset() or property_exists() should be used.
The get_magic_quotes_gpc() and get_magic_quotes_runtime()
functions are deprecated. They always return false
.
The hebrevc() function is deprecated.
It can be replaced with nl2br(hebrev($str))
or,
preferably, the use of Unicode RTL support.
The convert_cyr_string() function is deprecated. It can be replaced by one of mb_convert_string(), iconv() or UConverter.
The money_format() function is deprecated. It can be replaced by the intl NumberFormatter functionality.
The ezmlm_hash() function is deprecated.
The restore_include_path() function is deprecated.
It can be replaced by ini_restore('include_path')
.
Passing parameters to implode() in reverse order
is deprecated, use implode($glue, $parts)
instead of implode($parts, $glue)
.
Importing type libraries with case-insensitive constant registering has been deprecated.
FILTER_SANITIZE_MAGIC_QUOTES
is deprecated,
use FILTER_SANITIZE_ADD_SLASHES
instead.
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.
ldap_control_paged_result_response() and ldap_control_paged_result() are deprecated. Pagination controls can be sent along with ldap_search() instead.
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:
<?php
// ReflectionClass::export(Foo::class, false) is:
echo new ReflectionClass(Foo::class), "\n";
// $str = ReflectionClass::export(Foo::class, true) is:
$str = (string) new ReflectionClass(Foo::class);
?>
The AI_IDN_ALLOW_UNASSIGNED
and
AI_IDN_USE_STD3_ASCII_RULES
flags for
socket_addrinfo_lookup() are deprecated,
due to an upstream deprecation in glibc.