Reputation: 53525
If you had to guess what will be the output of the following php code:
$str = "011";
eval("\$num = $str;");
echo "number is: ".$num;
I bet you would never say "9". Well, neither did I...
I'd love to hear an explanation for this bizarre behavior!
Upvotes: 1
Views: 102
Reputation: 8487
Starting a digit with a leading 0 indicates base 8, in which 11 is 9.
Still confused? Read this: http://en.wikipedia.org/wiki/Octal
Upvotes: 5