3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Auto{ public $farba; public $nazov; public $rokVyroby; public function __construct($paFarba, $paNazov, $paRokVyroby){ $this->farba = $paFarba; $this->nazov = $paNazov; $this->nazov = $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>" ?>
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 Auto::__construct(), 2 passed in /in/WO9hZ on line 48 and exactly 3 expected in /in/WO9hZ:7 Stack trace: #0 /in/WO9hZ(48): Auto->__construct('Cierna', 'Audi') #1 {main} thrown in /in/WO9hZ on line 7
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 Auto::__construct(), 2 passed in /in/WO9hZ on line 48 and exactly 3 expected in /in/WO9hZ:7 Stack trace: #0 /in/WO9hZ(48): Auto->__construct('Cierna', 'Audi') #1 {main} thrown in /in/WO9hZ on line 7
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33
Warning: Missing argument 3 for Auto::__construct(), called in /in/WO9hZ on line 48 and defined in /in/WO9hZ on line 7 Notice: Undefined variable: paRokVyroby in /in/WO9hZ on line 10 Warning: Missing argument 3 for Auto::__construct(), called in /in/WO9hZ on line 48 and defined in /in/WO9hZ on line 7 Notice: Undefined variable: paRokVyroby in /in/WO9hZ on line 10 Warning: Missing argument 3 for Auto::__construct(), called in /in/WO9hZ on line 49 and defined in /in/WO9hZ on line 7 Notice: Undefined variable: paRokVyroby in /in/WO9hZ on line 10 Warning: Missing argument 3 for Auto::__construct(), called in /in/WO9hZ on line 49 and defined in /in/WO9hZ on line 7 Notice: Undefined variable: paRokVyroby in /in/WO9hZ on line 10 Warning: Missing argument 3 for Auto::__construct(), called in /in/WO9hZ on line 50 and defined in /in/WO9hZ on line 7 Notice: Undefined variable: paRokVyroby in /in/WO9hZ on line 10 Auto: Cierna Auto: Zlta Auto: Cervena Auto: Zelena Auto: Cervena Auto: Cierna Auto: Zelena Auto: Zlta <table border=1> Notice: Use of undefined constant length - assumed 'length' in /in/WO9hZ on line 65 </table>

preferences:
244.54 ms | 404 KiB | 335 Q