PHP
PHP
PHP Programming
Quiz Masters
BCA II Yrs.
1. What does PHP stand for?
i) Personal Home Page
ii) Hypertext Preprocessor
iii) Pretext Hypertext Processor
iv) Preprocessor Home Page
a) .html
b) .xml
c) .php
d) .ph
3. A PHP script should start with
___ and end with ___
a) < php >
b) < ? php ?>
c) <? ?>
d) <?php ?>
a) Only ii)
b) i), iii) and iv)
c) ii), iii) and iv)
d) Both ii) and iv)
<?php
$num = 1;
$num1 = 2;
print $num . "+". $num1;
?>
a) 3
b) 1+2
c) 1.+.2
d) Error
<?php
$num = "1";
$num1 = "2";
print $num+$num1;
?>
a) 3
b) 1+2
c) Error
d) 12
11. Which of following variables can be assigned a
value to it?
i) $3hello
ii) $_hello
iii) $this
iv) $This
<?php
$foo = 'Bob';
$bar = &$foo;
$bar = "My name is $bar";
echo $bar;
echo $foo;
?>
a) Error
b) My name is BobBob
c) My name is BobMy name is Bob
d) My name is Bob Bob
13. Which of the following PHP statements will
output Hello World on the screen?
i) echo (“Hello World”);
ii) print (“Hello World”);
iii) printf (“Hello World”);
iv) sprintf (“Hello World”);
a) i) and ii)
b) i), ii) and iii)
c) All of the mentioned
d) i), ii) and iv)
<?php
$color = "maroon";
$var = $color[2];
echo "$var";
?>
a) a
b) Error
c) $var
d) r
15. What will be the output of the following PHP code?
<?php
$score = 1234;
$scoreboard = (array) $score;
echo $scoreboard[0];
?>
a) 1
b) Error
c) 1234
d) 2
<?php
$total = "25 students";
$more = 10;
$total = $total + $more;
echo "$total";
?>
a) Error
b) 35 students
c) 35
d) 25 students
17. Which of the below
statements is equivalent to
$add += $add ?
a) $add = $add
b) $add = $add +$add
c) $add = $add + 1
d) $add = $add + $add + 1
a) echo “\$x”;
b) echo “$$x”;
c) echo “/$x”;
d) echo “$x;”;
19. What will be the output of the following code?
<?php
function track() {
static $count = 0;
$count++;
echo $count;
}
track();
track();
track();
?>
a) 123
b) 111
c) 000
d) 011
<?php
$a = "clue";
$a .= "get";
echo "$a";
?>
a) get
b) true
c) false
d) clueget
21. What will be the output of the
following PHP code?
<?php
$a = 5;
$b = 5;
echo ($a === $b);
?>
a) 5 === 5
b) Error
c) 1
d) False
<?php
$num = 10;
echo 'What is her age? \n She is $num years
old';
?>
a) Only i)
b) i), ii) and iv)
c) ii), iii) and iv)
d) All of the mentioned.
25. What will be the output of the following PHP
code?
<?php
$team = "arsenal";
switch ($team) {
case "manu":
echo "I love man u";
case "arsenal":
echo "I love arsenal";
case "manc":
echo "I love manc"; }
?>
a) I love arsenal
b) Error
c) I love arsenalI love manc
d) I love arsenalI love mancI love manu