Last active
December 19, 2015 12:49
-
-
Save code-poel/5957719 to your computer and use it in GitHub Desktop.
Annoying PHP quirk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$integer = new \SplInt( 5 ); | |
if( false === filter_var( $integer, FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 1, 'max_range' => 9 ) ) ) ) | |
{ | |
throw new \InvalidArgumentException( sprintf( 'An integer value of 1 through 9 is required, %s "%s" given.', gettype( $integer ), $integer ) ); | |
} | |
// Result: | |
// PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message | |
// 'An integer value of 1 through 9 is required, object "5" given.' in /SplInt.php:7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment