PHP 8.1.15 Released!

弃用的功能

PHP 核心

动态属性的使用

弃用动态属性创建,除非类选择使用 #[\AllowDynamicProperties] 注解。stdClass 允许动态属性。__get()/__set() 魔术方法不受此更改的影响。解决动态属性弃用警告,可以通过以下方式:

  • 声明属性(首选)。
  • #[\AllowDynamicProperties] 添加到 #[\AllowDynamicProperties](这也适用于所有子类)。
  • 如果需要将附加数据于不属于自己的对象相关联,则使用 WeakMap

Relative callables

弃用 $callable() 语法不接受的可调用对象(但 call_user_func() 接受)。尤其是:

  • "self::method"
  • "parent::method"
  • "static::method"
  • ["self", "method"]
  • ["parent", "method"]
  • ["static", "method"]
  • ["Foo", "Bar::method"]
  • [new Foo, "Bar::method"]
这不会影响正常方法调用,比如 "A::method"["A", "method"]

"${var}""${expr}" 样式插值

弃用字符串插值的 "${var}""${expr}" 样式。 Use "$var"/"{$var}" and "{${expr}}", respectively.

MBString

Usage of the QPrint, Base64, Uuencode, and HTML-ENTITIES 'text encodings' is deprecated for all MBString functions. Unlike all the other text encodings supported by MBString, these do not encode a sequence of Unicode codepoints, but rather a sequence of raw bytes. It is not clear what the correct return values for most MBString functions should be when one of these non-encodings is specified. Moreover, PHP has separate, built-in implementations of all of them; for example, UUencoded data can be handled using convert_uuencode()/convert_uudecode().

SPL

弃用内部方法 SplFileInfo::_bad_state_ex()

标准

弃用 utf8_encode()utf8_decode()

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top