3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class GeoCoder { protected $latitude; protected $longitude; public $distance; public function __construct($lat,$long,$dist) { $this->latitude = $lat; $this->longitude = $long; $this->distance = $dist; } } $o1 = new GeoCoder(-22.43,-46.81,1500.00); $o2 = new GeoCoder(-22.42,-46.82,1740.00); $o3 = new GeoCoder(-21.43,-46.80,152.00); $a = array($o1, $o2, $o3); foreach($a as $e){ sort($e); } var_dump($e);
based on 4YN63
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Warning: sort() expects parameter 1 to be array, object given in /in/HZ5Su on line 22 Warning: sort() expects parameter 1 to be array, object given in /in/HZ5Su on line 22 Warning: sort() expects parameter 1 to be array, object given in /in/HZ5Su on line 22 object(GeoCoder)#3 (3) { ["latitude":protected]=> float(-21.43) ["longitude":protected]=> float(-46.8) ["distance"]=> float(152) }
Output for hhvm-3.10.0 - 3.12.0
Warning: Invalid operand type was used: sort expects array(s) or collection(s) in /in/HZ5Su on line 22 Warning: Invalid operand type was used: sort expects array(s) or collection(s) in /in/HZ5Su on line 22 Warning: Invalid operand type was used: sort expects array(s) or collection(s) in /in/HZ5Su on line 22 object(GeoCoder)#3 (3) { ["latitude":protected]=> float(-21.43) ["longitude":protected]=> float(-46.8) ["distance"]=> float(152) }
Output for 5.0.0 - 5.2.17
Warning: sort() expects parameter 1 to be array, object given in /in/HZ5Su on line 22 Warning: sort() expects parameter 1 to be array, object given in /in/HZ5Su on line 22 Warning: sort() expects parameter 1 to be array, object given in /in/HZ5Su on line 22 object(GeoCoder)#3 (3) { ["latitude:protected"]=> float(-21.43) ["longitude:protected"]=> float(-46.8) ["distance"]=> float(152) }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/HZ5Su on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/HZ5Su on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/HZ5Su on line 4
Process exited with code 255.