Weird PHP behavior: won't assign the integer 8 to a variable

后端 未结 5 396
灰色年华
灰色年华 2021-01-28 13:18

I think I just encountered the strangest \'bug\' I\'ve ever encountered in my short developer life. It seems like I just can\'t assign the value eight to any variable. For exemp

5条回答
  •  孤独总比滥情好
    2021-01-28 14:05

    if you prefix your numbers with a zero (0) they are interpreted as octal numbers. 7 is the highest octal number. there’s also 0x for hexadecimal numbers (up to 15/F)

    how to fix: just don’t prefix with 0 ;)

提交回复
热议问题