If a number starts with 0 it is consider an octal number
and since these numbers range from 0 to 7 only. You get a 0 since 8%8 = 0
Reference: http://php.net/manual/en/language.types.integer.php
A side note on number systems
Have you wondered why the next number to 9 is 10? and why in the binary system the sequence is 0, 1, 10, 11... ? And why the octal system allows only values from 0 to 7?
It is because number systems usually increment values based on modulo logic on the base.
For example take the binary number system. Since it is base 2
, it can only contain values 0, 1 since 0%2 = 0, 1%2 = 1, but 2%2 is again 0
So whenever a greater number comes, say 3. Its value in binary is (increment by one in the preceding place) (put the modulo in the existing place)
So the value of 3 in the binary system is (0+1) (3%2) = 11
Though this is not the exact logic, just putting it here for a beginner reference