3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Auto{ public $farba; public $nazov; public $rokVyroby; public function __construct($paFarba, $paNazov, $paRokVyroby){ $this->farba = $paFarba; $this->nazov = $paNazov; $this->rokVyroby = $paRokVyroby; } public function getFarba(){ return $this->farba; } public function getNazov(){ return $this->nazov; } public function __toString(){ return "Auto: {$this->nazov} {$this->farba} {$this->rokVyroby}"; } } function compareNazov($obj1, $obj2){ return strcmp($obj1->nazov, $obj2->nazov); } function compareNazovZostupne($obj1, $obj2){ return -1*strcmp($obj1->nazov, $obj2->nazov); } function compareFarba($obj1, $obj2){ return strcmp($obj1->farba, $obj2->farba); } function compareFarbaZostupne($obj1, $obj2){ return -1*strcmp($obj1->farba, $obj2->farba); } $cars = array(new Auto("Cierna","Audi"),new Auto("Zlta", "Volvo"), new Auto("Cervena", "Skoda"), new Auto("Zelena", "Octavia")); $car = new Auto("Fialova", "Toyota"); $length = count($cars); for ($i = 0; $i < $length; $i++){ echo $cars[$i]; echo "\r\n"; } usort($cars, "compareFarba"); for ($i = 0; $i < $length; $i++){ echo $cars[$i]; echo "\r\n"; } echo "<table border=1>"; for ($x = 0; $x < length; $x++){ echo "<tr>"; echo "<td>" . $cars[$x]->nazov . "</td>"; echo "<td>" . $cars[$x]->farba . "</td>"; echo "<td>" . $cars[$x]->rokVyroby . "</td>"; echo "</tr>"; } echo "</table>" ?>
based on WO9hZ
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Auto::__construct(), 2 passed in /in/UR2Wr on line 48 and exactly 3 expected in /in/UR2Wr:7 Stack trace: #0 /in/UR2Wr(48): Auto->__construct('Cierna', 'Audi') #1 {main} thrown in /in/UR2Wr on line 7
Process exited with code 255.
Output for 5.3.19 - 7.0.20
Warning: Missing argument 3 for Auto::__construct(), called in /in/UR2Wr on line 48 and defined in /in/UR2Wr on line 7 Notice: Undefined variable: paRokVyroby in /in/UR2Wr on line 10 Warning: Missing argument 3 for Auto::__construct(), called in /in/UR2Wr on line 48 and defined in /in/UR2Wr on line 7 Notice: Undefined variable: paRokVyroby in /in/UR2Wr on line 10 Warning: Missing argument 3 for Auto::__construct(), called in /in/UR2Wr on line 49 and defined in /in/UR2Wr on line 7 Notice: Undefined variable: paRokVyroby in /in/UR2Wr on line 10 Warning: Missing argument 3 for Auto::__construct(), called in /in/UR2Wr on line 49 and defined in /in/UR2Wr on line 7 Notice: Undefined variable: paRokVyroby in /in/UR2Wr on line 10 Warning: Missing argument 3 for Auto::__construct(), called in /in/UR2Wr on line 50 and defined in /in/UR2Wr on line 7 Notice: Undefined variable: paRokVyroby in /in/UR2Wr on line 10 Auto: Audi Cierna Auto: Volvo Zlta Auto: Skoda Cervena Auto: Octavia Zelena Auto: Skoda Cervena Auto: Audi Cierna Auto: Octavia Zelena Auto: Volvo Zlta <table border=1> Notice: Use of undefined constant length - assumed 'length' in /in/UR2Wr on line 65 </table>