带有新闻和资料链接的新鲜选择。在发行版中:PHP 8发行时间表,对PHP对象的人体工程学分析以及来自PHP Internals的5个最新RFC的分析,一些有用的工具,视频,播客等等。享受阅读!
{public get, private set}
class Point { public float $x; public float $y; public float $z; public function __construct( float $x = 0.0, float $y = 0.0, float $z = 0.0 ) { $this->x = $x; $this->y = $y; $this->z = $z; } }
class Point { public function __construct( public float $x = 0.0, public float $y = 0.0, public float $z = 0.0 ) {} }
class Uri { private function __construct( ?string $scheme, ?string $user, ?string $pass, ?string $host, ?int $port, string $path, ?string $query, ?string $fragment // <-- ARGH! ) { ... } }
var_dump([] % [42]); // int(0) // WTF?
switch
$expressionResult = switch ($condition) { 1 => foo(), 2 => bar(), 3, 4, 5 => baz(), };
case
case 3, 4, 5: break;
case 3: case 4: case 5: break;
[(int) $now, (int) $future] = ["2020", "2021"]; // , [$now, $future] = ["2020", "2021"]; $now = (int) $now; $future = (int) $future;
...[int $i] = ['a' => '123']; function foo(...[int $i]) { } foo(['a' => '234']);
$var = (Foo) [ 'a' => 123, 'b' => (Bar) [ 'c' => // ... ], ];
感谢您的关注!如果您发现错误或不准确,请在PM中通知我。问题和建议写在邮件或推特上。有关PHP Digest Telegram Channel的更多新闻和评论。发送链接搜索所有摘要的链接← 先前版本:PHP Digest No. 176