PHP 8.0 phát hành
(php.net)-
Cải thiện tốc độ với hai engine JIT: Tracing JIT + Function JIT
-
Cải thiện hệ thống kiểu và xử lý lỗi
-
Named arguments
→ htmlspecialchars($string, double_encode: false);
- Attributes
→ #[Route("/api/posts/{id}", methods: ["GET"])]
- Constructor property promotion
→ __construct( public float $x = 0.0 ) {}
- Union Type
→ private int|float $number
- Match expression
→ match (8.0) { '8.0' => "Oh no!", 8.0 => "This is what I expected", };
- Nullsafe operator
→ $country = $session?->user?->getAddress()?->country;
- So sánh chuỗi với số hợp lý hơn
→ 0 == 'foobar' // false (trước đây là true)
- Bổ sung: lớp WeakMap, interface Stringable, các hàm str_contains(), str_starts_with(), str_ends_with()
2 bình luận
Hiện tại
empty("0") => true, còn trong 8 thì sẽ ra sao?!Trên bản 8 vẫn y như vậy nhỉ haha