PHP 8.0 リリース
(php.net)-
2つのJITエンジンにより速度を改善 : Tracing JIT + Function JIT
-
型システムとエラー処理の改善
-
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;
- より妥当な文字列と数値の比較
→ 0 == 'foobar' // false(以前は true だった)
- 追加 : WeakMap クラス、Stringable インターフェース、str_contains()、str_starts_with()、str_ends_with() 関数
2件のコメント
今は
empty("0") => trueですが、8では果たして?!8でもそのままですね(笑)