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'));
Output for git.master, git.master_jit
int(1) float(100) string(7) "unknown"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
49.13 ms | 786 KiB | 4 Q