PHP Question: Octal Values
Question
If I assign and print a value like this:
$a = 012;
print $a;
I get back a value of '10', why?
PHP questions suitable for use in interviews or just for fun.
If I assign and print a value like this:
$a = 012;
print $a;
I get back a value of '10', why?
What's the difference between include() and require()?
What will the following snippet print, and why?
$count = 0;
print $count++;
What will the following code print, and why?
echo TRUE;
What is printed after the following code has been run?
function calc() {
$a = 1000;
return $a;
}
$a = 1;
calc();
print $a;
As part of a new series of posts I will be creating a set of PHP questions suitable for use in interviews or just for fun. They will range from the very easy to very difficult but are all designed to test one or two specific parts of the PHP language. The idea is not to test for knowledge of the order of PHP function parameters (which I often have to look up), but more to test if the candidate knows how the language works. It is also quite a good mechanism to post about some of the fundamentals of the PHP language.