MIKESTOWE.COM

you are here

Weekly PHP Test

What is the output of the following code?

PHP
1
echo (string) 042;

ANSWER:

1
34

Because the number starts with a zero, it is interpreted as an Octal number instead of a decimal. This means instead of returning 42 as one might expect, it returns the octal calculation:

0 = signify Octal
4 = 4 x 8 = 32
2 = 2 X 1 = 2
—————-
34

Share this Page:
Facebook Twitter Linkedin Reddit Tumblr Email

Leave a Reply

Your email address will not be published. Required fields are marked *