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; function __construct($storename) { $this->storename = $storename; } function buy() { echo "本を売りました"; } } $store1 = new BookStore("未来書店"); echo $store1->storename; $store->buy();
Output for git.master_jit, git.master
未来書店 Warning: Undefined variable $store in /in/MTldN on line 67 Fatal error: Uncaught Error: Call to a member function buy() on null in /in/MTldN:67 Stack trace: #0 {main} thrown in /in/MTldN on line 67
Process exited with code 255.

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.71 ms | 713 KiB | 4 Q