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 { switch ($code) { case 1: $label = 'active'; break; case 2: $label = 'disabled'; break; default: $label = 'unknown'; break; } return $label; } var_dump(statusLabel('1'));
Output for 8.2.31 - 8.2.33, 8.3.0 - 8.3.33, 8.4.1 - 8.4.25, 8.5.0 - 8.5.10
int(1) float(100) string(6) "active"

preferences:
61.3 ms | 787 KiB | 4 Q