新特性
命名参数
htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
// PHP 8
// Specify only required parameters, skipping optional ones.
// Arguments are order-independent and self-documented.
htmlspecialchars($string, double_encode: false);
nullsafe操作符
<?php
declare(strict_types=1);
class User {
public function getAddress() {}
}
$user = new User();
$country = $user?->getAddress()?->country?->iso_code;
dump($country);