It relates to octal numbers, 042 interpreted as the octal number 42 , which is 4 * 8 + 2 = 34 .
Remember that octal interpretation occurs when a numeric letter is parsed when loading a PHP script. It has nothing to do with intval() , which does nothing here, because the value is already an integer.
Octal interpretation occurs only with numeric literals, and not when casting a string to an integer:
intval(042) // == 34 intval('042') // == 42 (int)'042' // == 42
AndreKR
source share