3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Auto{ private $farba; private $nazov; public function __construct($paFarba, $paNazov){ $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 M8PVb
Output for 7.2.0
Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/9sbF5 on line 38 Notice: Undefined index: i in /in/9sbF5 on line 38 <br> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/9sbF5 on line 38 Notice: Undefined index: i in /in/9sbF5 on line 38 <br> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/9sbF5 on line 38 Notice: Undefined index: i in /in/9sbF5 on line 38 <br> Warning: usort() expects parameter 1 to be array, null given in /in/9sbF5 on line 42 Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/9sbF5 on line 44 Notice: Undefined index: i in /in/9sbF5 on line 44 <br> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/9sbF5 on line 44 Notice: Undefined index: i in /in/9sbF5 on line 44 <br> Warning: Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /in/9sbF5 on line 44 Notice: Undefined index: i in /in/9sbF5 on line 44 <br>
Output for 5.3.19 - 7.1.10
Notice: Use of undefined constant i - assumed 'i' in /in/9sbF5 on line 38 Notice: Undefined index: i in /in/9sbF5 on line 38 <br> Notice: Use of undefined constant i - assumed 'i' in /in/9sbF5 on line 38 Notice: Undefined index: i in /in/9sbF5 on line 38 <br> Notice: Use of undefined constant i - assumed 'i' in /in/9sbF5 on line 38 Notice: Undefined index: i in /in/9sbF5 on line 38 <br> Warning: usort() expects parameter 1 to be array, null given in /in/9sbF5 on line 42 Notice: Use of undefined constant i - assumed 'i' in /in/9sbF5 on line 44 Notice: Undefined index: i in /in/9sbF5 on line 44 <br> Notice: Use of undefined constant i - assumed 'i' in /in/9sbF5 on line 44 Notice: Undefined index: i in /in/9sbF5 on line 44 <br> Notice: Use of undefined constant i - assumed 'i' in /in/9sbF5 on line 44 Notice: Undefined index: i in /in/9sbF5 on line 44 <br>