3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function foo($path) { if ($path && $path[0] = '/') { $path = substr($path, 1); } $url = 'http://' . 'www.example.com/' . $path; echo $url, PHP_EOL; return $url; } foo('/abc'); foo('abc'); foo('/'); foo('');
based on 9clh3
Output for 4.3.10 - 4.4.9, 5.0.2 - 7.2.0
http://www.example.com/abc http://www.example.com/bc http://www.example.com/ http://www.example.com/
Output for 4.3.3 - 4.3.9, 5.0.0 - 5.0.1
http://www.example.com/abc Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/KAb7K on line 7 PHP_EOLhttp://www.example.com/bc Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/KAb7K on line 7 PHP_EOLhttp://www.example.com/ Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/KAb7K on line 7 PHP_EOLhttp://www.example.com/ Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/KAb7K on line 7 PHP_EOL
Output for 4.3.0 - 4.3.2
http://www.example.com//abc Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/KAb7K on line 7 PHP_EOLhttp://www.example.com//bc Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/KAb7K on line 7 PHP_EOLhttp://www.example.com// Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/KAb7K on line 7 PHP_EOLhttp://www.example.com/ Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/KAb7K on line 7 PHP_EOL