PHP Version
- 每个版本支持 2 年,+1 年安全修复
- 参考
Version | date | active/eol |
---|---|---|
PHP 8.4 | ||
PHP 8.3 | 2023-11-23 | 2025-11-31 |
PHP 8.2 | 2022-12-08 | 2024-11-31 |
PHP 8.1 | 2021-11-25 | 2023-12-28 |
PHP 8.0 | 2020-11-26 | |
PHP 7.4 | 2019-11-28 | 2022-11-28 |
PHP 8.4
- JIT
- new JIT implementation based on IR https://php.watch/rfcs/jit-ir
PHP 8.3
- lint -
php -l
json_validate
gc_status
class_alias
<?php
class Test {
// Typed Class Constants
const string TEST_CONSTANT = 'test';
}
$constName = 'TEST_CONSTANT';
// Dynamic class constant and Enum member fetch support
echo MyClass::{$constName};
PHP 8.2
- readonly 类
<?php
readonly class BlogData
{
public string $title;
public Status $status;
public function __construct(string $title, Status $status)
{
$this->title = $title;
$this->status = $status;
}
}
- Disjunctive Normal Form (DNF) 类型
<?php
class Foo {
public function bar((A&B)|null $entity) {
return $entity;
}
}
- null, false, true 作为独立类型
- trait 支持包含 const
- 参考
PHP 8.1
- fiber
- amphp
- enum
<?php
enum Status
{
case Draft;
case Published;
case Archived;
}
- readonly 属性
<?php
class BlogData
{
public readonly Status $status;
public function __construct(Status $status)
{
$this->status = $status;
}
}