Thursday, April 10, 2014

Elance PHP5 Test Questions

Question.1: The setrawcookie() method of setting cookies is different from PHP standard method of cookie setting as:

a. It does not allow expiry time to be set
b. It can be used only once
c. It does not URL-ENCODE the value on its own
d. It does not allow domain setting


Question.2How can you hide the fact that web pages are written in PHP?

a. By using AddType application/X-httpd-php asp
b. Specify all file names without any dot and extension
c. By using .htaccess diretive in Apeche
d. All of the above


Question.3: Which composite data types are supported by php?

Answer: Array


Question.4: The default value of register_globals in PHP is:

Answer: Off


Question.5: If the session_cache_expire() is not set, then by default the session cache will expire after:

Answer: 3 hrs


Question.6: Which variable declarations within a class is invalid in PHP5?

Answer: var $term =3;


Question.7: What will be the output of the following code?
$a = 0.0;
for ($i = 0; $i < a =”=”">

Answer: 1
Question.8: What will be the output of the following code?
$j=30;
$k=0;
$k=$j++/$i++;
echo $i . ” ” . $j . ” ” . $k . ” “;

Answer: 5 31 7.5


Question.9: Following is a php code block:

$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + –$z;
echo $z;
what will be the output?

Answer: 18


Question.10: With reference to the following php script:

print ‘Text Line1'
print ‘Text Line2'
?>

What will be the output on running the script?

Answer: Error message will be printed


Question.11: Which of the following does not represent logical AND operator in PHP?

Answer: &amp


Question.12: Which is not true for a persistent connection?

Answer: These can’t be converted to non-persistent connections.



Question.13: What will be the output of following code?

$arr = “a”;
$arr[0]=”b”;
echo $arr;
echo $arr[0];

Answer: bb


Question.14: What will be the output of following code?

$var1=”a”;
$$var1=”b”;
echo “$var1 $a”;

Answer: a b


Question.15:What is the output of the following code?

$a = 500;
$b = 200;
echo $a % 2
* $b;
?>

Answer: 0


Question.16: What will be the output of the following code?

echo 12 . 6;

Answer: 126


Question.17: Consider the following sample code:

$x = 0xFFFE;
$y = 2;
$z = $x && $y;

What will be the value of $z?

Answer: 1


Question.18: The Manager and Office classes are as follows:

class Manager{
function printName() {
echo "Manager";
}
}
class Office{
function getManager() {
return new Manager();
}
}
$ofc = new Office();
???
?>

Which of the following should replace '???' to obtain the value of printName() function?

Answer: $ofc->getManager()->printName();


Question.19: Which  is the correct way of specifying default value?

Answer: function GetDiscount($Type = "Special") { . . . }


Question.20: Following is a php code block:

$m=9;
$n=99;
$z=8;
$z=$n++/$m++ + --$z;
echo $z;
what will be the output?

Answer: 18


Question.21: Which is a not a correct way of commenting in php?

Answer: /#PHP Comment


 Question.22: Which composite data types are supported by php?


Answer: Array

No comments:

Post a Comment