3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function formatPhoneNumber(string $phonenumber) { $phonenumber = str_replace([' ', '-', '.', '(', ')'], '', $phonenumber); if (strpos($phonenumber, '00') === 0) { $phonenumber = '+' . substr($phonenumber, 2); } if (strpos($phonenumber, '+310') === 0) { $phonenumber = '+31' . substr($phonenumber, 4); } if (strpos($phonenumber, '+') === 0) { return $phonenumber; } if (strlen($phonenumber) === 10 && strpos($phonenumber, '06') === 0) { return '+31' . ltrim($phonenumber, '0'); } return $phonenumber; } echo formatPhoneNumber('+31 (0) 6 123 45 678');
based on Qoeol
Output for hhvm-3.15.4, 7.0.0 - 7.3.1
+31612345678
Output for 5.6.0 - 5.6.30
Catchable fatal error: Argument 1 passed to formatPhoneNumber() must be an instance of string, string given, called in /in/Ou1Sq on line 23 and defined in /in/Ou1Sq on line 3
Process exited with code 255.