3v4l.org

run code in 300+ PHP versions simultaneously
<?php function filter_host($host) { var_dump('hosts', $host); $t = ($host === 'localhost' || preg_match('/[^0-9a-z\.]/', $host)); var_dump('t', $t); $t ? false : $host; } $r = call_user_func('filter_host', 'test.hosts.simplecheck123'); var_dump('r', $r); var_dump('test', false ? 'false' : 'true');
Output for 5.6.0 - 5.6.23, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
string(5) "hosts" string(25) "test.hosts.simplecheck123" string(1) "t" bool(false) string(1) "r" NULL string(4) "test" string(4) "true"

preferences:
212.2 ms | 404 KiB | 223 Q