1

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 ?

John Conde
  • 217,595
  • 99
  • 455
  • 496

1 Answers1

8

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.

John Conde
  • 217,595
  • 99
  • 455
  • 496