3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ReformatPhoneNumber($number) { if(!preg_match('#^\d(\d[\? ]?){5,10}\d$#')) { throw new Exception('Invalid phone number'); } return str_replace(array('-', ' '), '', $number); } $a = array('01234567', '-12345678', '01--23457', '111111112345', '111-111-339-1-1-0', '01110111-', '1237'); foreach($a as $b) { try{ var_dump(ReformatPhoneNumber($b)); } catch(Exception $e) {} }
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught ArgumentCountError: preg_match() expects at least 2 arguments, 1 given in /in/rCDkv:4 Stack trace: #0 /in/rCDkv(4): preg_match('#^\\d(\\d[\\? ]?){...') #1 /in/rCDkv(13): ReformatPhoneNumber('01234567') #2 {main} thrown in /in/rCDkv on line 4
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
44.58 ms | 401 KiB | 8 Q