htmlspecialchars(
$string,
ENT_QUOTES | ENT_SUBSTITUTE,
'UTF-8',
true
);htmlspecialchars(
$string,
double_encode: false,
encoding: 'UTF-8',
);class User
{
/**
* @Route("/api/users", methods={"GET"})
*/
public function index()
{
// ...
}
}class User
{
#[Route('/api/users', methods: ['GET'])]
public function index()
{
// ...
}
}class Point
{
public float $x;
public float $y;
public function __construct(
float $x = 0.0,
float $y = 0.0
) {
$this->x = $x;
$this->y = $y;
}
}class Point
{
public function __construct(
public float $x = 0.0,
public float $y = 0.0
) {
}
}$result = '';
switch ($status) {
case 200:
case 300:
$result = 'OK';
break;
default:
$result = 'Error';
break;
}$result = match ($status) {
200, 300 => 'OK',
default => 'Error',
};