3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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>"; } ?>
based on RSBq0
Output for 7.2.0
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 5.3.19 - 7.1.10
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>