Search code examples
phpcastingintegeroctal

How does Casting work in PHP?


What doesn't this work:

(int)08 == (int)09==0

But this and this does?

(int)07==7 
(int)06==6 

Solution

  • 08 is in octal base (because it starts with a 0), hence it is invalid. See the documentation.