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); $nu = null; if ($o1->distance > $o2->distance) { $nu[0] = $o2; $nu[1] = $o1; } else if ($o1->distance > $o3->distance) { $nu[0] = $o3->distance; $nu[2] = $o1->distance; } else { $nu[0] = $o1; $nu[1] = $o2; } var_dump($nu);
based on tGoV7
Output for 5.0.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
array(2) { [0]=> float(152) [2]=> float(1500) }
Output for hhvm-3.10.0

Process exited with code 153.
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/AGaHi 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/AGaHi 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/AGaHi on line 4
Process exited with code 255.