Ans : Hello $x
2. What value is $x in this PHP section of code "function foo ($i) {return ((($i*2)-3)%3); } $x = foo(6);"
Ans : 0
3. In PHP, what is the value of $x when '$x = 10 - "2 elephants";'
Ans : 8
4. In PHP, if $a is TRUE and $b is TRUE, what is ($a xor $b)?.
Ans : False
5. What will the output of this PHP code be 'function x () { function y()
{ return "y"; } return "x"; } echo y();'
Ans: Fatal error: Call to undefined function: y()
6. If table x has an integer column y and there are three rows in the
table with values 45, 34 and 1, what is the output of this MySQL
statement "select count(*), count(y), sum(y), min(y), round(avg(y),2) from x;"
Ans : 3 3 80 1 26.67
7. With a table x (y int(10), z int(10)) having data of 1 1, 2 1, 3 4, 4 2, 5 1 (where first number is y, second number is z (there are 5 rowsof data)), what is the output of this MySQL statement "select count(y) from x group by z having count(y) > 1;"
Ans: 4
8. What is the MySQL output of this statement "select date_add('2004-10-11',interval -2 month);"
Ams: 2004-08-11
9. If the current date/time is 2004-10-14 13:05:34, what would be the output of the MySQL statement "select date_format(sysdate(),'%b-%Y-%d-%i');"
ANS :October-2004-14-13
10.Is it possible to set a time expire page in PHP.?
Yes it is
Using header(“Expires: fri, 07 mar 2007 05:00:00 GMT”);
11.How can we SAVE an image from a remote web Server to my web server using PHP?
$file_rimg = fopen("http://w3answers /image23.jpg",'rb');
$newfile_name_img = "/tmp/tutorial.file";
$file_wnew = fopen($newfile_name_img,'wb');
while (!feof($file_rimg)) {
$chunk_rd = fread($file_rimg,1024);
fwrite($file_wnew,$chunk_rd);
}
fclose($file_wnew);
fclose(file_rimg);
?>
12.What is the output of 2^2 in php ?
The answer is 0 (Zero)
Important note
Everyone expected answer would be 4. But answer is zero. How it happened only in php ?
The ^ operator is different in each language.In PHP ^ means the bitwise exlusive or of the two numbers.
13.What is the output of below script?
a. echo ‘line 3′;
b. echo ‘line 2′;
c. Error
d. None of the above
Ans: b (Answer is line2)
14.What is the output here?
$x = ‘raj’;
echo ‘Hello $x’;
?>
a. helloravj
b. Parse error
c. hello $x
d. syntax error
ANS: c
15.What output do you get here?
$list = array(“block”,”cut”,”pens”,”dogs”);
$list[] = “elephant”;
$list[] = “dragon”;
print “$list[4]“;
?>
a. Error
b. elephant
c. dragon
d. nothing
e. dogs
ANS: b (elephant)
16.what is the output for following code?
echo 12+FALSE;
?>
a. 12
b. no
c. parse error
d. T_ECHO error
e. FALSE
ANS: 12
17.What is the output ?
$x=7;
if ($x < 2) { echo “11″; }
elseif ($x < 16) { echo “12″; }
elseif ($x < 14) { echo “13″; }
elseif ($x > 14) { echo “14″; }
elseif ($x < 10) { echo “15″; }
else { echo “16″; }
?>
a.16
b.15
c.12
d.13
ANS:12
18.What is the result here?$x = '';
switch ($x) {
case '0': echo 'String'; br;
case 0: echo ''; break;
case NULL: echo 'NULL'; br;
case FALSE: echo 'heeder'; br;
case '': echo 'no string'; br;
default: echo 'nothing else'; br;
}
?>
b. Empty string
c. Integer
d. String
ANS: b[case 0: echo ''];
19.What is the output?
function x ($y) {
function y ($z) {
return ($z*2); }
return($y+3); }
$y = 4;
$y = x($y)*y($y);
echo “$y”;
?>
a. None
b. 54
c. 56
d. 58
ANS:56