3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Auto{ private $farba; private $nazov; public function __construct($paFarba, $paNazov){ echo "konstruktor"; $this->farba = $paFarba; $this->nazov = $paNazov; } public function getFarba(){ return $this->farba; } public function getNazov(){ return $this->nazov; } public function __toString(){ return "Auto: {$this->nazov} {$this->farba}"; } public function compareNazov($obj1, $obj2){ return strcmp($obj1->nazov, $obj2->nazov); } public function compareFarba($obj1, $obj2){ return strcmp($obj1->farba, $obj2->farba); } } $cars = array(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 "<br>"; } usort($your_data, "compareNazov"); for ($i = 0; $i < $length; $i++){ echo $cars[i]; echo "<br>"; } ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
konstruktorkonstruktorkonstruktorkonstruktor Fatal error: Uncaught Error: Undefined constant "i" in /in/M8PVb:39 Stack trace: #0 {main} thrown in /in/M8PVb on line 39
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
konstruktorkonstruktorkonstruktorkonstruktor Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/M8PVb on line 39 Notice: Undefined index: i in /in/M8PVb on line 39 <br> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/M8PVb on line 39 Notice: Undefined index: i in /in/M8PVb on line 39 <br> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/M8PVb on line 39 Notice: Undefined index: i in /in/M8PVb on line 39 <br> Warning: usort() expects parameter 1 to be array, null given in /in/M8PVb on line 43 Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/M8PVb on line 45 Notice: Undefined index: i in /in/M8PVb on line 45 <br> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/M8PVb on line 45 Notice: Undefined index: i in /in/M8PVb on line 45 <br> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/M8PVb on line 45 Notice: Undefined index: i in /in/M8PVb on line 45 <br>
Output for 7.3.32 - 7.3.33
konstruktorkonstruktorkonstruktorkonstruktor Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/M8PVb on line 39 <br> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/M8PVb on line 39 <br> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/M8PVb on line 39 <br> Warning: usort() expects parameter 1 to be array, null given in /in/M8PVb on line 43 Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/M8PVb on line 45 <br> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/M8PVb on line 45 <br> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/M8PVb on line 45 <br>
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
konstruktorkonstruktorkonstruktorkonstruktor Notice: Use of undefined constant i - assumed 'i' in /in/M8PVb on line 39 Notice: Undefined index: i in /in/M8PVb on line 39 <br> Notice: Use of undefined constant i - assumed 'i' in /in/M8PVb on line 39 Notice: Undefined index: i in /in/M8PVb on line 39 <br> Notice: Use of undefined constant i - assumed 'i' in /in/M8PVb on line 39 Notice: Undefined index: i in /in/M8PVb on line 39 <br> Warning: usort() expects parameter 1 to be array, null given in /in/M8PVb on line 43 Notice: Use of undefined constant i - assumed 'i' in /in/M8PVb on line 45 Notice: Undefined index: i in /in/M8PVb on line 45 <br> Notice: Use of undefined constant i - assumed 'i' in /in/M8PVb on line 45 Notice: Undefined index: i in /in/M8PVb on line 45 <br> Notice: Use of undefined constant i - assumed 'i' in /in/M8PVb on line 45 Notice: Undefined index: i in /in/M8PVb on line 45 <br>

preferences:
226.15 ms | 404 KiB | 334 Q