3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Fish { public $common_name; public $flavor; public $record_weight; function __construct($name, $flavor, $record){ $this->common_name = $name; $this->flavor = $flavor; $this->record_weight= $record; } public function getInfo(){ return "A Largemouth Bass is an Excellent flavored fish. The world record weight is 22 pounds 5 ounces." . $this->$common_name . $this->$flavor . $this->$record_weight; } } $f = new Fish(); $bass = new Fish("Largemouth Bass","Excellent","22 pounds 5 ounces"); echo $f->getInfo();
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Fish::__construct(), 0 passed in /in/017ZY on line 26 and exactly 3 expected in /in/017ZY:11 Stack trace: #0 /in/017ZY(26): Fish->__construct() #1 {main} thrown in /in/017ZY on line 11
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught ArgumentCountError: Too few arguments to function Fish::__construct(), 0 passed in /in/017ZY on line 26 and exactly 3 expected in /in/017ZY:11 Stack trace: #0 /in/017ZY(26): Fish->__construct() #1 {main} thrown in /in/017ZY on line 11
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Warning: Missing argument 1 for Fish::__construct(), called in /in/017ZY on line 26 and defined in /in/017ZY on line 11 Warning: Missing argument 2 for Fish::__construct(), called in /in/017ZY on line 26 and defined in /in/017ZY on line 11 Warning: Missing argument 3 for Fish::__construct(), called in /in/017ZY on line 26 and defined in /in/017ZY on line 11 Notice: Undefined variable: name in /in/017ZY on line 12 Notice: Undefined variable: flavor in /in/017ZY on line 13 Notice: Undefined variable: record in /in/017ZY on line 14 Notice: Undefined variable: common_name in /in/017ZY on line 19 Fatal error: Uncaught Error: Cannot access empty property in /in/017ZY:19 Stack trace: #0 /in/017ZY(28): Fish->getInfo() #1 {main} thrown in /in/017ZY on line 19
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Warning: Missing argument 1 for Fish::__construct(), called in /in/017ZY on line 26 and defined in /in/017ZY on line 11 Warning: Missing argument 2 for Fish::__construct(), called in /in/017ZY on line 26 and defined in /in/017ZY on line 11 Warning: Missing argument 3 for Fish::__construct(), called in /in/017ZY on line 26 and defined in /in/017ZY on line 11 Notice: Undefined variable: name in /in/017ZY on line 12 Notice: Undefined variable: flavor in /in/017ZY on line 13 Notice: Undefined variable: record in /in/017ZY on line 14 Notice: Undefined variable: common_name in /in/017ZY on line 19 Fatal error: Cannot access empty property in /in/017ZY on line 19
Process exited with code 255.

preferences:
203.64 ms | 402 KiB | 226 Q