3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //$email = 'johnsnow123@ヒキワリ.ナットウ.fr'; $email = 'johnsnow@192.168.1.1'; $localAndDomain = explode('@', $email); if (count($localAndDomain) !== 2) { echo 'invalid'; return; } $local = $localAndDomain[0]; $localExpression = '^[a-z0-9_-]+(?:[a-z0-9._%+-]+)*$'; if (mb_eregi($localExpression, $local) === false) { echo 'invalid'; return; } // Handle IDN domains $domain = $localAndDomain[1]; $domain = str_replace('xn--', '', idn_to_ascii($domain)); $dictionary = array('aero', 'arpa', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel'); $domainExpression = '^(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+(?:[A-Z]{2}|' . implode('|', $dictionary) . ')$'; if (mb_eregi($domainExpression, $domain) === false) { echo 'invalid'; return; } echo 'valid';
Output for 5.4.0 - 7.1.0
invalid
Output for 5.0.0 - 5.3.29
Fatal error: Call to undefined function idn_to_ascii() in /in/lrJgj on line 20
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: idn_to_ascii() in /in/lrJgj on line 20
Process exited with code 255.
Output for 4.3.4 - 4.4.4
Fatal error: Call to undefined function: idn_to_ascii() in /in/lrJgj on line 20
Process exited with code 255.
Output for 4.3.2 - 4.3.3
Fatal error: Call to undefined function: mb_eregi() in /in/lrJgj on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: mb_eregi() in /in/lrJgj on line 13