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", 1991),new Auto("Zlta", "Volvo", 1992), new Auto("Cervena", "Skoda", 1993), new Auto("Zelena", "Octavia", 1994)); $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 UR2Wr
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Auto::__construct(), 2 passed in /in/1FW62 on line 50 and exactly 3 expected in /in/1FW62:7 Stack trace: #0 /in/1FW62(50): Auto->__construct('Fialova', 'Toyota') #1 {main} thrown in /in/1FW62 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/1FW62 on line 50 and defined in /in/1FW62 on line 7 Notice: Undefined variable: paRokVyroby in /in/1FW62 on line 10 Auto: Audi Cierna 1991 Auto: Volvo Zlta 1992 Auto: Skoda Cervena 1993 Auto: Octavia Zelena 1994 Auto: Skoda Cervena 1993 Auto: Audi Cierna 1991 Auto: Octavia Zelena 1994 Auto: Volvo Zlta 1992 <table border=1> Notice: Use of undefined constant length - assumed 'length' in /in/1FW62 on line 65 </table>