Priti's Technical Corner

June 24, 2009

PHP Quiz


Test yourself !!

Question 1:
$a = 4;
for ($b = 0; $b <= $a; $b++) {
$c++;
}
Answer : 5

Question 2:
$a = “abc”;
$b = substr($a, 0, -1);
Answer : ab

Question 3:
$a = “0”;
$b = “0”;
if ($a != “1” && $b == “1” || $a != “0” || $b != “1” ){
$d = “0”;
}else{
$d = “1”;
}
Answer : 0

Question 4:
$a = “who_are_you”;
$b = array(“who_”, “_”);
$c = array(“”, ” “);
$d = ucwords(str_replace($b,$c,$a));

Answer :Are You

Question 5:
$c = “<tt>some</tt><b>hi</b>”;
preg_match(“/<\w?>(\w*?)<\/\w?>/”,$c,$p);
echo $p;
Answer : hi

Advertisements

Blog at WordPress.com.

%d bloggers like this: