Reputation: 99
In PHP, I haved tried this code print 08+"51";
but I don't know why it gives 51, while print 07+"51";
give 58 ?
Upvotes: 1
Views: 66
Reputation: 219884
Because when an integer starts with a 0 you are using octal. 08 is not a valid octal number so it translates to zero. 0 + 51 (because "51" is converted to a integer thanks to type juggling) equals 51.
Upvotes: 8