Not sure about results from print variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Not sure about results from print variable

Post by amir »

Hello,

If I assign 123 in variable a, it prints 123 but if I assign 0123 in variable a, it prints 83, why?

Code: Select all

$a = 123;
print $a;  // prints 123

$a = 0123;
print $a;  // prints 83
Thanks.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

The leading zero makes php interpret your value as an octal value.
Post Reply