Edit report at https://bugs.php.net/bug.php?id=63705&edit=1
ID: 63705 Comment by: iam4webwork at hotmail dot com Reported by: iam4webwork at hotmail dot com Summary: lack of error message Status: Not a bug Type: Bug Package: *General Issues PHP Version: Irrelevant Block user comment: N Private report: N New Comment: I respectfully disagree with the Father of PHP about octals only being octals if they have precisely one and only one leading zero. Here is my proof: $a = 012; $b = 0012; $c = 00012; var_dump($a,$b,$c); // all are int 10 in PHP5.4 If $b and $c were not octals then one might expect them to evaluate as 12 or be rejected as invalid data. The failure to provide error messages with respect to poorly formed octals is indeed a bug and can lead to weird comparisons like this: 0777 == 0777812 // true Previous Comments: ------------------------------------------------------------------------ [2012-12-06 07:53:44] ni...@php.net @rasmus: I still think that we should throw a notice/warning (in the lexer?) when an invalid octal is provided. Or do we have odd BC reasons preventing us from doing so? ------------------------------------------------------------------------ [2012-12-06 06:12:31] ras...@php.net Octals are by definition identified by a single leading 0, not 2. ------------------------------------------------------------------------ [2012-12-06 06:08:09] iam4webwork at hotmail dot com Description: ------------ PHP fails to display error messages consistently when user provides invalid octals. Test script: --------------- $octal = 00812; $another = 00934; var_dump( $octal, $another); $will_error = 01c; var_dump( $will_error ); The first two octals PHP accepts as valid input, and silently truncates each. It only displays an error message for 01c and mentions the 'c' being a problem. Why doesn't PHP consistently reject invalid octal values and display error messages? Expected result: ---------------- I expected error messages to result for each of the first two invalid octals. Instead PHP blindly accepted them while having each evaluate as zero. It only caught on to 01c being a bad octal value. Actual result: -------------- int 0 int 0 Parse error: syntax error, unexpected 'c' (T_STRING) in ... ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63705&edit=1