PHP Interview Questions - VI
1. What will be the out put of the above code?
<?php
$s = 2;
function Test()
{
echo "s = $s";
}
Test();
?>
Answers :
a) 1
b) 2
c) 3
d) No value
Explanation :
The variable $s have only local scope.
In order to reference
a global variable from a function the "global" keyword must
be used inside the function.
2. What will be the out put of the above code?
<?php
$x=array("aaa","ttt","www","ttt","yyy","tttt","www");
$y=array_count_values($x);
echo $y[ttt];
?>
Answers :
a) 2
b) 3
c) 1
d) 4
Explanation :
print_r(
array_count_values($x )) will print the following array go through it then
you can understand what is happening with
array_count_values($x)Array ( [aaa] => 1 [ttt] => 2 [www] => 2
[yyy] => 1
[tttt] => 1
)
I hope you get the working if you are not clear with this answer mail me
3.
|
4.
|
No comments:
Post a Comment