Insomania Insomania -4 years ago 140
PHP Question

Integer value is converting into a Surprisingly Number. [PHP]

i am facing an unexpected issue in php, when i try to echo a number then it is printing a different number on the browser. Please take a look:

echo 04240;

it will print

Which is really surprising.

Is there anyone who knows what's happening here? I tried to find it out but all in vain.


Answer Source

Because initial string has 0 in the first place, PHP consider this number as octal.

When you convert 04240 from octal into decimal like this:

0 + 4*8 + 2*8*8 + 4*8*8*8

You will get 2208 decimal number.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download