Edit report at http://bugs.php.net/bug.php?id=54524&edit=1
ID: 54524 Updated by: ahar...@php.net Reported by: dosergio at ig dot com dot br Summary: intval doesn't throw warning when value is bigger than the maximum allowed -Status: Open +Status: Bogus Type: Bug Package: *General Issues Operating System: all PHP Version: Irrelevant Block user comment: N Private report: N New Comment: No, it doesn't. This is expected and documented behaviour. Previous Comments: ------------------------------------------------------------------------ [2011-04-13 16:17:29] dosergio at ig dot com dot br Description: ------------ If you use intval with an argument that is bigger than 2147483647 the result will always be 2147483647. That's a problem that PHP doesn't throw an Error or Warning, because at the first glance, it looks like a mistery from where comes this magic number ? If someone used intval with an argument that is bigger than 2147483647 IMHO php should die with some message like this: 'Warning: Argument too big for intval. Maximum allowed is 2147483647' or 'Error: Argument too big for intval. Maximum allowed is 2147483647' I lost almost one hour to discover from where the magic number came... If there was the Error or Warning, it would be MUCH EASIER to solve the problem. Test script: --------------- <?php echo intval('11111111111'); ?> Expected result: ---------------- Throwing an Error (die) or Warning showing that the argument passed for intval was TOO BIG. Actual result: -------------- The function does NOT give any type of hint of the problem, and returns a fixed value 2147483647 as result, DOES NOT MATTER what the argument is, as long as it is bigger than 2147483647... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54524&edit=1