Why does this code only print zero? Why does it not print the value of a?
<?php
$a=099;
echo $a;
?>
Why does this code only print zero? Why does it not print the value of a?
<?php
$a=099;
echo $a;
?>
As Ultimater points out, you have assigned $a to an invalid octal number.
A numeric value (known as an "integer literal" in this case) prefaced with a zero is assumed by the parser to be an octal (base 8) number. As your number contains nines, which are not in the base (base 8 digits are 0-7), it's not valid and the parser evaluates it to zero.
For example, this does work:
$a = 077;
echo $a; //63