upgrade to php 8 code example
Example 1: php 8
latest version of php.
see new features at https://php.watch/versions/8.0
Example 2: php8
// php 8 Union type
class Number {
public function __construct(
private int|float $number
) {}
}
new Number('NaN'); // TypeError
Example 3: php8
// php8 class and construct
class Point {
public function __construct(
public float $x = 0.0,
public float $y = 0.0,
public float $z = 0.0,
) {}
}