3v4l.org

run code in 500+ PHP versions simultaneously
<?php class HelloWorld { public function sayHello(): string { return 'Hello, World!'; } } $date = new HelloWorld(); $a = match (true) { $date instanceof HelloWorld => 1, default => false }; var_dump($a); function applyDiscount(int $tier, float $price): float { switch ($tier) { case 1: $price = $price * 0.9; break; case 2: $price = $price * 0.8; break; } return $price; } var_dump(applyDiscount('9', 100.0)); function statusLabel($code): string { return match ($code) { 1 => 'active', 2 => 'disabled', default => 'unknown', }; } var_dump(statusLabel('1'));

preferences:
51.79 ms | 788 KiB | 5 Q