3v4l.org

run code in 300+ PHP versions simultaneously
<?php # https://stackoverflow.com/a/32451875/429071 # Will accept any string along as it _also_ contains a single uppercase or number character $str = "Has a single uppercase character only."; $pattern = '/[A-Z0-9]/'; checkStringForPattern($str, $pattern); # https://stackoverflow.com/a/32451873/429071 # Will accept any string as long as it contains _either_ an uppercase or number character $str = "WILLACCEPTTHISSTRING"; $pattern = '/^[A-Z0-9]+$/'; checkStringForPattern($str, $pattern); $str = "0123456789"; $pattern = '/^[A-Z0-9]+$/'; checkStringForPattern($str, $pattern); # The following regex will need *both* types $pattern = "/^(?=.*[A-Z])(?=.*[0-9])[A-Z0-9]*$/"; $str = "WILLFAILBECAUSEITONLYCONTAINSLETTERS"; checkStringForPattern($str, $pattern); $str = "0123456789"; checkStringForPattern($str, $pattern); function checkStringForPattern($str, $pattern){ if(preg_match($pattern, $str)){ var_dump("The [$pattern] pattern accepts the [$str] string."); }else{ var_dump("The [$pattern] does NOT accept the [$str] string."); } }
Output for rfc.property-hooks, git.master, git.master_jit
string(85) "The [/[A-Z0-9]/] pattern accepts the [Has a single uppercase character only.] string." string(70) "The [/^[A-Z0-9]+$/] pattern accepts the [WILLACCEPTTHISSTRING] string." string(60) "The [/^[A-Z0-9]+$/] pattern accepts the [0123456789] string." string(108) "The [/^(?=.*[A-Z])(?=.*[0-9])[A-Z0-9]*$/] does NOT accept the [WILLFAILBECAUSEITONLYCONTAINSLETTERS] string." string(82) "The [/^(?=.*[A-Z])(?=.*[0-9])[A-Z0-9]*$/] does NOT accept the [0123456789] string."

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:
45.34 ms | 899 KiB | 4 Q