3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function checkEmail($email) { return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email); } function checkEmail2($email) { return (bool)preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email); } if (function_exists('eregi')){ echo "eregi:\n"; var_dump(checkEmail("jim@example.com")); var_dump(checkEmail("jim@example.comm")); } echo "preg_match:\n"; var_dump(checkEmail2("jim@example.com")); var_dump(checkEmail2("jim@example.comm"));
based on seCdK
Output for 7.0.28 - 7.3.0rc3
preg_match: bool(true) bool(false)
Output for 5.6.38
eregi: Deprecated: Function eregi() is deprecated in /in/tdtuY on line 4 int(1) Deprecated: Function eregi() is deprecated in /in/tdtuY on line 4 bool(false) preg_match: bool(true) bool(false)