3v4l.org

run code in 300+ PHP versions simultaneously
<?php function stringValidator($field) { if(!empty($field) && preg_match('~[^a-z\d]~i', $field)) { return "You typed $field: please don't use special characters '<' '>' '_' '/' etc."; } return "valid"; // empty or valid } $strings = ["hello", "what_the"]; foreach ($strings as $string) { echo "$string: " , stringValidator($string) , "\n"; }

preferences:
28.85 ms | 404 KiB | 5 Q