3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php // the filter_* functions trim whitespace which can result in data loss var_dump(filter_var(" 1 ", FILTER_VALIDATE_INT)); // because filter_var casts passed values to a string, it accepts various unsafe values var_dump(filter_var(true, FILTER_VALIDATE_INT)); var_dump(filter_var(new NotAnInt(), FILTER_VALIDATE_INT)); var_dump(filter_var(1.00000000000001, FILTER_VALIDATE_INT)); class NotAnInt { function __toString() { return " 1"; } }
based on OK3RF
Output for 5.2.0 - 7.2.6
int(1) int(1) int(1) int(1)
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function filter_var() in /in/ESUbN on line 4
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: filter_var() in /in/ESUbN on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: filter_var() in /in/ESUbN on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: filter_var() in /in/ESUbN on line 4