3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); $userScoreA = 80; $userScoreB = 79; function judgeScore(int $score = 0): string { if($score >= 80) { $result = "{$score}点は合格です"; } else { $result = "{$score}点は不合格です"; } return $result; } // echo judgeScore($userScoreA); // echo judgeScore($userScoreB); // echo judgeScore(); function shopping(int $price, int $quantity) :string { $total = $price * $quantity; $result = "合計金額は{$total}円です"; return $result; } // echo shopping(500, 3); function movie(int $age): string { if($age <=12) { return "チケット料金は800円です"; } else if ( $age <= 64 ) { return "チケット料金は1800円です"; } else { return "チケット料金は1100円です"; } } // echo movie(10); function bmi(float $height, int $weight): string { $m = $height / 100; $bmi = $weight / ($m * $m); $roundBmi = round($bmi, 1); if($roundBmi < 18.5) { return "BMIは{$roundBmi}です。低体重です"; } else if ($roundBmi < 25) { return "BMIは{$roundBmi}です。普通体重です"; } else { return "BMIは{$roundBmi}です。肥満です"; } } // echo bmi(164,84); class BookStore{ public string $storename; public string $bookname; public string $outher; public function __construct(string $storename, string $bookname) { $this->storename = $storename; $this->bookname = $bookname; } public function buy() { echo "本を売りました"; } } $store1 = new BookStore("未来書店","走れメロス"); echo $store1->storename; $store1->buy(); echo $store1->bookname; class Cafe{ public string $storename; public string $menu; public int $price; private int $int = 0; function __construct(string $storename, string $menu, int $price) { $this->storename = $storename; $this->menu = $menu; $this->price = $price; } public function order() : void { echo "{$this->menu}を注文しました"; } } $cafe1 = new Cafe("コメダ","コーヒー", 300); $cafe1->order(); class Hospital { public string $name; public string $sinryouka; private int $price; function __construct(string $name, string $sinryouka, int $price) { $this->name = $name; $this->sinryouka = $sinryouka; $this->price = $price; } function priceFunc(): int { return $this->price; } function price(): void{ echo "{$this->$sinryouka}で診察しました。料金は{$this->$priceFunc}です。"; } } $hospital1 = new Hospital("阪大","免疫内科",5000); $hospital2 = new Hospital("京大","消化器内科",3000); $hospital1->price(); $hospital2->price();

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.30.0340.00516.59
8.5.20.0340.00716.70
8.5.10.0350.00916.57
8.5.00.0330.00816.54
8.4.180.0360.01419.64
8.4.170.0280.01219.67
8.4.160.0260.01119.78
8.4.150.0130.00919.93
8.4.140.0220.01317.97
8.4.130.0370.01017.47
8.4.120.0270.01417.72
8.4.110.0440.01117.78
8.4.100.0400.01117.75
8.4.90.0460.00517.68
8.4.80.0390.00818.02
8.4.70.0370.00917.91
8.4.60.0350.01218.10
8.4.50.0380.01018.07
8.4.40.0520.00617.72
8.4.30.0390.00817.79
8.4.20.0440.00617.77
8.4.10.0430.00917.84
8.3.300.0290.01118.48
8.3.290.0340.00818.41
8.3.280.0310.01018.47
8.3.270.0360.01116.85
8.3.260.0390.00816.59
8.3.250.0350.00917.12
8.3.240.0340.01016.68
8.3.230.0310.00516.85
8.3.220.0160.00416.98
8.3.210.0230.00616.76
8.3.200.0160.00516.79
8.3.190.0330.01116.89
8.3.180.0380.01416.52
8.3.170.0350.01116.80
8.3.160.0380.01016.70
8.3.150.0350.01216.96
8.3.140.0370.01016.78
8.3.130.0340.00716.80
8.3.120.0320.01116.63
8.3.110.0320.01216.80
8.3.100.0450.00716.83
8.3.90.0400.00816.80
8.3.80.0410.00716.81
8.3.70.0390.01016.74
8.3.60.0390.00816.75
8.3.50.0350.01216.86
8.3.40.0310.01218.10
8.3.30.0290.01117.88
8.3.20.0260.01018.05
8.3.10.0280.00818.05
8.3.00.0220.00817.86

preferences:
43.15 ms | 762 KiB | 5 Q