You are on page 1of 3

1. Which of following variables can be assigned 4.

Which of the below symbols is a newline


a value to it? character?

i) $3hello a) \r

ii) $_hello b) \n

iii) $this c) /n

iv) $This d) /r

a) All of the mentioned 5. What will be the output of the following PHP
code?
b) Only ii)
<?php
c) ii), iii) and iv)
$num = 10;
d) ii) and iv)
echo 'What is her age? \n She is $num years
2. Which of the following PHP statements will old';
output Hello World on the screen?
?>
i) echo (“Hello World”);
a) What is her age? \n She is $num years old
ii) print (“Hello World”);
b) What is her age?
iii) printf (“Hello World”);
She is $num years old
iv) sprintf (“Hello World”);
c) What is her age? She is 10 years old
a) i) and ii)
d) What is her age?
b) i), ii) and iii)
She is 10 years old
c) All of the mentioned
6. Which of the conditional statements is/are
d) i), ii) and iv) supported by PHP?
3. Which of the below statements is equivalent i) if statements
to $add += $add ?
ii) if-else statements
a) $add = $add
iii) if-elseif statements
b) $add = $add +$add
iv) switch statements
c) $add = $add + 1
a) Only i)
d) $add = $add + $add + 1
b) i), ii) and iv)
c) ii), iii) and iv) c) 0

d) All of the mentioned. d) -1

7. If $a = 12 what will be returned when ($a == 11. Which one of the following is the right way
12) ? 5 : 1 is executed? of defining a function in PHP?

a) 12 a) function { function body }

b) 1 b) data type functionName(parameters) {


function body }
c) Error
c) functionName(parameters) { function body }
d) 5
d) function fumctionName(parameters) {
8. Who is the father of PHP? function body }
a) Rasmus Lerdorf 12. What will happen in this function call?
b) Willam Makepiece <?php
c) Drek Kolkevi
function calc($price, $tax)
d) List Barely {
9. Which of the following are correct ways of $total = $price + $tax;
creating an array?
}
i) state*0+ = “karnataka”;
$pricetag = 15;
ii) $state[] = array(“karnataka”);
$taxtag = 3;
iii) $state*0+ = “karnataka”;
calc($pricetag, $taxtag);
iv) $state = array(“karnataka”);
?>
a) iii) and iv)
a) Call By Value
b) ii) and iii)
b) Call By Reference
c) Only i)
c) Default Argument Value
d) ii), iii) and iv)
d) Type Hinting
10. PHP’s numerically indexed array begin with
position ___________ 13. What will be the output of the following
PHP code?
a) 1
<?php
b) 2
function calc($price, $tax="") b) I am bI am a

{ c) Error

$total = $price + ($price * $tax); d) I am a Error

echo "$total"; 15. What will be the output of the following


PHP code?
}
<?php
calc(42);
$op2 = "blabla";
?>
function foo($op1)
a) Error
{
b) 0
echo $op1;
c) 42
echo $op2;
d) 84
}
14. What will be the output of the following
PHP code? foo("hello");

<?php ?>

function a() a) helloblabla

{ b) Error

function b() c) hello

{ d) helloblablablabla

echo 'I am b';

echo 'I am a';

b();

a();

?>

a) I am b

You might also like