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(); class Hotel{ public string $name; public string $type; private int $price; function __construct(string $name, string $type, int $price) { $this->name = $name; $this->type = $type; $this->price = $price; } function price(): int { return $this->price; } function checkin(): void { echo "{$this->type}タイプのお部屋にチェックインしました。料金は{$this->price()}円です"; } } // $checkin1 = new Hotel("アパホテル", "シングル", 8000); // $checkin2 = new Hotel("リゾートホテル", "ダブル", 20000); // $checkin1->checkin(); // $checkin2->checkin(); class Restaurant{ public string $name; public string $menu; private int $price; function __construct(string $name,string $menu,int $price) { $this->name = $name; $this->menu = $menu; $this->price = $price; } function price(): int{ return $this->price; } function order(): void { echo "{$this->name}を注文しました。お値段は{$this->price()}円です。"; } } $order1= new Restaurant("都ホテル", "スイートポテト", 300); $order2= new Restaurant("ガスト", "スパゲティ", 780); $order3 = new Restaurant("王将","ぎょうざ",400); $order1->order(); $order2->order(); $order3->order();

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.0290.00816.64
8.5.20.0290.01116.81
8.5.10.0330.00916.73
8.5.00.0380.00616.79
8.4.180.0330.00919.79
8.4.170.0340.01219.67
8.4.160.0240.01319.79
8.4.150.0160.00819.74
8.4.140.0330.00717.40
8.4.130.0310.00817.88
8.4.120.0300.00818.11
8.4.110.0310.01418.07
8.4.100.0410.00817.98
8.4.90.0400.01018.00
8.4.80.0360.00818.18
8.4.70.0350.01018.11
8.4.60.0360.01117.92
8.4.50.0360.01117.97
8.4.40.0400.00717.91
8.4.30.0390.00817.65
8.4.20.0380.01217.67
8.4.10.0450.00717.70
8.3.300.0370.00618.51
8.3.290.0110.01118.37
8.3.280.0160.00718.43
8.3.270.0360.00816.68
8.3.260.0330.01116.69
8.3.250.0330.01016.86
8.3.240.0350.01016.82
8.3.230.0290.00616.51
8.3.220.0310.01116.68
8.3.210.0370.00916.64
8.3.200.0330.00916.71
8.3.190.0350.00716.53
8.3.180.0370.01016.64
8.3.170.0440.00916.44
8.3.160.0390.00816.73
8.3.150.0380.00816.63
8.3.140.0380.00616.79
8.3.130.0360.00616.57
8.3.120.0320.01116.66
8.3.110.0310.00916.75
8.3.100.0350.01216.67
8.3.90.0370.01016.79
8.3.80.0380.01416.83
8.3.70.0390.00816.63
8.3.60.0410.00616.79
8.3.50.0350.00916.66
8.3.40.0400.00617.85
8.3.30.0280.01617.72
8.3.20.0260.00917.98
8.3.10.0310.00618.05
8.3.00.0270.00917.91

preferences:
42.07 ms | 742 KiB | 5 Q