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 $method) { echo "{$this->$menu}を注文しました"; } } $cafe1 = new Cafe("コメダ","コーヒー", 300); echo $cafe1->method;
Output for git.master_jit, git.master
未来書店本を売りました走れメロス Warning: Undefined variable $menu in /in/kCW3H on line 78 Warning: Undefined property: Cafe::$ in /in/kCW3H on line 78 を注文しました Warning: Undefined property: Cafe::$method in /in/kCW3H on line 83

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:
43.34 ms | 715 KiB | 4 Q