Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2K views

PHP PDF

The document provides information about PHP including: - PHP stands for Hypertext Preprocessor - PHP files have a .php file extension by default - Common PHP code syntax is <?php ?> - PHP supports functions, loops, conditional statements - Rasmus Lerdorf created PHP

Uploaded by

Kshitij Nayak
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

PHP PDF

The document provides information about PHP including: - PHP stands for Hypertext Preprocessor - PHP files have a .php file extension by default - Common PHP code syntax is <?php ?> - PHP supports functions, loops, conditional statements - Rasmus Lerdorf created PHP

Uploaded by

Kshitij Nayak
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 276

PHP

1. What does PHP stand for?

i) Personal Home Page

ii) Hypertext Preprocessor

iii) Pretext Hypertext Processor

iv) Preprocessor Home Page

a) Both i) and iii)

b) Both ii) and iv)

c) Only ii)

d) Both i) and ii)

Answer: d

2. PHP files have a default file extension of_______

a) .html

b) .xml

c) .php

d) .ph

Answer: c

Explanation: To run a php file on the server, it should be saved as AnyName.php

3. What should be the correct syntax to write a PHP code?

a) < php >

b) < ? php ?>

c) <? ?>

d) <?php ?>

Answer: c

4. Which of the following is/are a PHP code editor?

i) Notepad
ii) Notepad++

iii) Adobe Dreamweaver

iv) PDT

a) Only iv)

b) i), ii), iii) and iv)

c) i), ii) and iii)

d) Only iii)

Answer: b

5. Which of the following must be installed on your computer so as to run PHP script?

i) Adobe Dreamweaver

ii) XAMPP

iii) Apache and PHP

iv) IIS

a) i), ii), iii) and iv)

b) Only ii)

c) ii) and iii)

d) ii), iii) and iv)

Answer: d

6. Which version of PHP introduced Try/catch Exception?

a) PHP 4

b) PHP 5

c) PHP 6

d) PHP 5 and later

Answer: d

7. How should we add a single line comment in our PHP code?

i) /?

ii) //
iii) #

iv) /* */

a) Only ii)

b) i), iii) and iv)

c) ii), iii) and iv)

d) Both ii) and iv)

Answer: c

8. Which of the following PHP statement/statements will store 111 in variable num?

i) int $num = 111;

ii) int mum = 111;

iii) $num = 111;

iv) 111 = $num;

a) Both i) and ii)

b) i), ii), iii) and iv)

c) Only iii)

d) Only i)

Answer: c

Explanation: You need not specify the datatype in php.

9. What will be the output of the following PHP code?

<?php

$num = 1;

$num1 = 2;

print $num . "+". $num1;

?>

a) 3

b) 1+2
c) 1.+.2

d) Error

Answer: b

10. What will be the output of the following PHP code?

<?php

$num = "1";

$num1 = "2";

print $num+$num1;

?>

a) 3

b) 1+2

c) Error

d) 12

Answer: a

11. Which is the right way of declaring a variable in PHP?

i) $3hello

ii) $_hello

iii) $this

iv) $This

a) Only ii)

b) Only iii)

c) ii), iii) and iv)

d) ii) and iv)

Answer: d

12. What will be the output of the following PHP code?

<?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

Answer: c

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) i), ii), iii) and iv)

d) i), ii) and iv)

Answer: b

14. What will be the output of the following PHP code?

<?php

$color = "maroon";

$var = $color[2];

echo "$var";
?>

a) a

b) Error

c) $var

d) r

Answer: d

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

Answer: c

16. What will be the output of the following PHP code?

<?php

$total = "25 students";

$more = 10;

$total = $total + $more;

echo "$total";

?>

a) Error

b) 35 students

c) 35
d) 25 students

Answer: c

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

Answer: b

18. Which statement will output $x on the screen?

a) echo “\$x”;

b) echo “$$x”;

c) echo “/$x”;

d) echo “$x;”;

Answer: a

19. What will be the output of the following PHP code?

<?php

function track() {

static $count = 0;

$count++;

echo $count;

track();

track();

track();

?>

a) 123

b) 111
c) 000

d) 011

Answer: a

20. What will be the output of the following PHP code?

<?php

$a = "clue";

$a .= "get";

echo "$a";

?>

a) get

b) true

c) false

d) clueget

Answer: d

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

Answer: c
22. Which of the below symbols is a newline character?

a) \r

b) \n

c) /n

d) /r

Answer: b

23. What will be the output of the following PHP code?

<?php

$num = 10;

echo 'What is her age? \n She is $num years old';

?>

a) What is her age? \n She is $num years old

b)What is her age?

She is $num years old

c) What is her age? She is 10 years old

d)What is her age?

She is 10 years old

Answer: a

24. Which of the conditional statements is/are supported by PHP?

i) if statements

ii) if-else statements

iii) if-elseif statements

iv) switch statements

a) Only i)

b) i), ii) and iv)

c) ii), iii) and iv)


d) i), ii), iii) and iv)

Answer: d

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

Answer: c

26. Which of the looping statements is/are supported by PHP?

i) for loop

ii) while loop

iii) do-while loop

iv) foreach loop

a) i) and ii)

b) i), ii) and iii)

c) i), ii), iii) and iv)


d) Only iv)

Answer: c

27. What will be the output of the following PHP code?

<?php

$user = array("Ashley", "Bale", "Shrek", "Blank");

for ($x=0; $x < count($user); $x++) {

if ($user[$x] == "Shrek") continue;

printf ($user[$x]);

?>

a) AshleyBale

b) AshleyBaleBlank

c) ShrekBlank

d) Shrek

Answer: b

28. If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?

a) 12

b) 1

c) Error

d) 5

Answer: d

29. What will be the value of $a and $b after the function call in the following PHP code?

<?php

function doSomething( &$arg ) {

$return = $arg;

$arg += 1;

return $return;

}
$a = 3;

$b = doSomething( $a );

?>

a) a is 3 and b is 4

b) a is 4 and b is 3

c) Both are 3

d) Both are 4

Answer: b

30. Who is the father of PHP?

a) Rasmus Lerdorf

b) Willam Makepiece

c) Drek Kolkevi

d) List Barely

Answer: a

31. How to define a function in PHP?

a) function {function body}

b) data type functionName(parameters) {function body}

c) functionName(parameters) {function body}

d) function functionName(parameters) {function body}

Answer: d

32. Type Hinting was introduced in which version of PHP?

a) PHP 4

b) PHP 5

c) PHP 5.3

d) PHP 6

Answer: b

33. Which type of function call is used in line 8 in the following PHP code?

<?php
function calc($price, $tax)

$total = $price + $tax;

$pricetag = 15;

$taxtag = 3;

calc($pricetag, $taxtag);

?>

a) Call By Value

b) Call By Reference

c) Default Argument Value

d) Type Hinting

Answer: a

34. What will be the output of the following PHP code?

<?php

function calc($price, $tax="")

$total = $price + ($price * $tax);

echo "$total";

calc(42);

?>

a) Error

b) 0

c) 42

d) 84

Answer: c

35. Which of the following are valid function names?


i) function()

ii) €()

iii) .function()

iv) $function()

a) Only i)

b) Only ii)

c) i) and ii)

d) iii) and iv)

Answer: b

36. What will be the output of the following PHP code?

<?php

function a()

function b()

echo 'I am b';

echo 'I am a';

a();

a();

?>

a) I am a

b) I am bI am a

c) Error

d) I am a Error

Answer: a

37. What will be the output of the following PHP code?


<?php

function a()

function b()

echo 'I am b';

echo 'I am a';

b();

a();

?>

a) I am b

b) I am bI am a

c) Error

d) I am a Error

Answer: c

38. What will be the output of the following PHP code?

<?php

$op2 = "blabla";

function foo($op1)

echo $op1;

echo $op2;

foo("hello");

?>

a) helloblabla
b) Error

c) hello

d) helloblablablabla

Answer: c

39. A function in PHP which starts with __ (double underscore) is known as __________

a) Magic Function

b) Inbuilt Function

c) Default Function

d) User Defined Function

Answer: a

40. What will be the output of the following PHP code?

<?php

function foo($msg)

echo "$msg";

$var1 = "foo";

$var1("will this work");

?>

a) Error

b) $msg

c) 0

d) Will this work

Answer: d

41. Which of the following PHP functions accepts any number of parameters?

a) func_get_argv()

b) func_get_args()

c) get_argv()
d) get_argc()

Answer: b

42. Which one of the following PHP functions can be used to find files?

a) glob()

b) file()

c) fold()

d) get_file()

Answer: a

43. Which of the following PHP functions can be used to get the current memory usage?

a) get_usage()

b) get_peak_usage()

c) memory_get_usage()

d) memory_get_peak_usage()

Answer: c

44. Which of the following PHP functions can be used for generating unique ids?

a) uniqueid()

b) id()

c) md5()

d) mdid()

Answer: a

45. Which one of the following functions can be used to compress a string?

a) zip_compress()

b) zip()

c) compress()

d) gzcompress()

Answer: d

46. What will be the output of the following PHP code?

<?php
echo chr(52);

?>

a) 1

b) 2

c) 3

d) 4

Answer: d

47. What will be the output of the following PHP code?

<?php

echo ord ("hi");

?>

a) 106

b) 103

c) 104

d) 209

Answer: c

48. What will be the output of the following PHP code?

<?php

$str = "Hello World";

echo wordwrap($str,5,"<br>\n");

?>

a) Hello World

b)

Hello

World

c)
Hell

o wo

rld

d) World

Answer: b

49. What will be the output of the following PHP code?

<?php

echo ucwords("i love my country");

?>

a) I love my country

b) i love my Country

c) I love my Country

d) I Love My Country

Answer: d

50. What will be the output of the following PHP code?

<?php

echo lcfirst("welcome to India");

?>

a) welcome to India

b) welcome to india

c) Welcome to India

d) Welcome to india

Answer: a

51. PHP’s numerically indexed array begin with position ___________

a) 1

b) 2

c) 0

d) -1
Answer: c

52. Which of the following are correct ways of creating an array?

i) state[0] = "karnataka";

ii) $state[] = array("karnataka");

iii) $state[0] = "karnataka";

iv) $state = array("karnataka");

a) iii) and iv)

b) ii) and iii)

c) Only i)

d) ii), iii) and iv)

Answer: a

53. What will be the output of the following PHP code?

<?php

$states = array("Karnataka" => array

("population" => "11,35,000", "capital" => "Bangalore"),

"Tamil Nadu" => array( "population" => "17,90,000",

"capital" => "Chennai") );

echo $states["Karnataka"]["population"];

?>

a) Karnataka 11,35,000

b) 11,35,000

c) population 11,35,000

d) Karnataka population

Answer: b

54. Which of the following PHP function will return true if a variable is an array or false if it is not an
array?

a) this_array()

b) is_array()
c) do_array()

d) in_array()

Answer: b

55. Which in-built function will add a value to the end of an array?

a) array_unshift()

b) into_array()

c) inend_array()

d) array_push()

Answer: d

56. What will be the output of the following PHP code?

<?php

$state = array ("Karnataka", "Goa", "Tamil Nadu",

"Andhra Pradesh");

echo (array_search ("Tamil Nadu", $state) );

?>

a) True

b) 1

c) False

d) 2

Answer: d

57. What will be the output of the following PHP code?

<?php

$fruits = array ("apple", "orange", "banana");

echo (next($fruits));

echo (next($fruits));

?>

a) orangebanana

b) appleorange
c) orangeorange

d) appleapple

Answer: a

58. Which of the following function is used to get the value of the previous element in an array?

a) last()

b) before()

c) prev()

d) previous()

Answer: c

59. What will be the output of the following PHP code?

<?php

$fruits = array ("apple", "orange", array ("pear", "mango"),

"banana");

echo (count($fruits, 1));

?>

a) 3

b) 4

c) 5

d) 6

Answer: d

60. Which function returns an array consisting of associative key/value pairs?

a) count()

b) array_count()

c) array_count_values()

d) count_values()

Answer: c

61. What will be the output of the following PHP code?

<?php
$cars = array("Volvo", "BMW", "Toyota");

echo "I like " . $cars[2] . ", " . $cars[1] . " and " . $cars[0] . ".";

?>

a) I like Volvo, Toyota and BMW

b) I like Volvo, BMW and Toyota

c) I like BMW, Volvo and Toyota

d) I like Toyota, BMW and Volvo

Answer: d

62. What will be the output of the following PHP code?

<?php

$fname = array("Peter", "Ben", "Joe");

$age = array("35", "37", "43");

$c = array_combine($age, $fname);

print_r($c);

?>

a) Array (Peter Ben Joe)

b) Array ([Peter] => 35 [Ben] => 37 [Joe] => 43)

c) Array (35 37 43)

d) Array ([35] => Peter [37] => Ben [43] => Joe)

Answer: d

63. What will be the output of the following PHP code?

<?php

$a=array("A","Cat","Dog","A","Dog");

$b=array("A","A","Cat","A","Tiger");

$c=array_combine($a,$b);

print_r(array_count_values($c));

?>

a) Array ( [A] => 5 [Cat] => 2 [Dog] => 2 [Tiger] => 1 )


b) Array ( [A] => 2 [Cat] => 2 [Dog] => 1 [Tiger] => 1 )

c) Array ( [A] => 6 [Cat] => 1 [Dog] => 2 [Tiger] => 1 )

d) Array ( [A] => 2 [Tiger] => 1 )

Answer: d

64. What will be the output of the following PHP code?

<?php

$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");

$a2 = array("e" => "red", "f" => "green", "g" => "blue", "h" => "orange");

$a3 = array("i" => "orange");

$a4 = array_merge($a2, $a3);

$result = array_diff($a1, $a4);

print_r($result);

?>

a) Array ( [d] => yellow )

b) Array ( [i] => orange )

c) Array ( [h] => orange )

d) Array ( [d] => yellow [h] => orange )

Answer: a

65. What will be the output of the following PHP code?

<?php

$a1 = array("red", "green");

$a2 = array("blue", "yellow");

$a3 = array_merge($a1, $a2);

$a4 = array("a", "b", "c", "d");

$a = array_combine($a4, $a3);

print_r($a);

?>

a) Array ( [a] => blue [b] => yellow [c] => red [d] => green )
b) Array ( [0] => blue [1] => yellow [2] => red [3] => green )

c) Array ( [0] => red [1] => green [2] => blue [3] => yellow )

d) Array ( [a] => red [b] => green [c] => blue [d] => yellow )

Answer: d

66. What will be the output of the following PHP code?

<?php

$a = array("a" => "india", "b" => "brazil", "c" => "china");

echo array_shift($a);

echo "<br>";

array_pop($a);

print_r($a);

?>

a)

india

Array ( [b] => Brazil )

b)

india

Array ( [a] => brazil )

c)

china

Array ( [a] => india )

d)

china

Array ( [a] => brazil )


Answer: a

67. What will be the output of the following PHP code?

<?php

$a1 = array_fill(1, 4, "hello");

$b1 = array_fill(5, 1, "php");

$a2 = array_merge($a1, $a2);

print_r($a2);

echo "<br>";

print_r($b1);

?>

a)

Array ( [1] => hello [4] => hello [5] => php )

Array ( [5] => php )

b)

Array ( [1] => hello [2] => hello [3] => hello [4] => hello )

Array ( [5] => php )

c)

Array ( [1] => hello [2] => hello [3] => hello [4] => hello [5] => php )

Array ( [5] => php )

d)

Array ( [1] => hello [2] => hello [3] => hello [4] => hello )

Array ( [1] => php )

Answer: c

68. What will be the output of the following PHP code?


<?php

$names = array("Sam", "Bob", "Jack");

echo $names[0] . "is the brother of " . $names[1] . " and " . $names[1] . ".";

?>

a) Sam is the brother of Bob and Jack

b) Samis the brother of Bob and Bob

c) Sam is the brother of Jack and Bob

d) Error

Answer: b

69. What will be the output of the following PHP code?

<?php

$names = array("Sam", "Bob", "Jack");

echo $names[0]."is the brother of ".$names[1]." and ".$names[1].".".$brother;

?>

a) Sam is the brother of Bob and Bob) $brother

b) Sam is the brother of Bob and Bob)

c) $brother

d) Error

Answer: d

70. What will be the output of the following PHP code?

<?php

$place = array("NYC", "LA", "Paris");

array_pop($place);

$place1 = array("Paris");

$place = array_merge($place, $place1);

print_r($place);

?>

a) Array ( [0] => LA [1] => Paris [2] => Paris )


b) Array ( [0] => NYC [1] => LA [2] => Paris)

c) Array ( [0] => NYC [1] => LA [2] => Paris [3] => Paris )

d) Array ( [0] => LA [1] => Paris )

Answer: b

71. What will be the output of the following PHP code?

<?php

$age = array("Harry" => "21", "Ron" => "23","Malfoy" => "21");

array_pop($age);

print_r(array_change_key_case($age, CASE_UPPER));

?>

a) Array ( [Harry] => 21 [Ron] => 23 [Malfoy] => 21 )

b) Array ( [HARRY] => 21 [RON] => 23 [MALFOY] => 21 )

c) Array ( [HARRY] => 21 [RON] => 23 )

d) Array ( [Harry] => 21 [Ron] => 23 )

Answer: c

72. What will be the output of the following PHP code?

<?php

$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");

$result = array_flip($a1);

print_r($result);

?>

a) Array ( [red] => red [green] => green [blue] => blue [yellow] => yellow )

b) Array ( [a] => a [b] => b [c] => c [d] => d )

c) Array ( [red] => a [green] => b [blue] => c [yellow] => d )

d) Array ( [a] => red [b] => green [c] => blue [d] => yellow )

Answer: c

73. What will be the output of the following PHP code?

<?php
$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");

$a2 = array("e" => "red","f" => "green", "g" => "blue");

$result = array_intersect($a1, $a2);

print_r($result);

?>

a) Array ( [a] => red [b] => green [c] => blue )

b) Array ( [a] => red [b] => green [c] => blue [d] => yellow )

c) Array ( [e] => red [f] => green [g] => blue )

d) Array ( [a] => red [b] => green [c] => blue [d] => yellow [e] => red [f] => green [g] => blue )

Answer: a

74. What will be the output of the following PHP code?

<?php

$a = array(12, 5, 2);

echo(array_product($a));

?>

a) 024

b) 120

c) 010

d) 060

Answer: b

75. What will be the output of the following PHP code?

<?php

$a = array("a" => "Jaguar", "b" => "Land Rover",

"c" => "Audi", "d" => "Maseratti");

echo array_search("Audi", $a);

?>

a) a

b) b
c) c

d) d

Answer: c

76. What will be the output of the following PHP code?

<?php

$city_west = array("NYC", "London");

$city_east = array("Mumbai", "Beijing");

print_r(array_replace($city_west, $city_east));

?>

a) Array ( [1] => Mumbai [0] => Beijing )

b) Array ( [0] => NYC [1] => London )

c) Array ( [1] => NYC [0] => London )

d) Array ( [0] => Mumbai [1] => Beijing )

Answer: d

77. What will be the output of the following PHP code?

<?php

$people = array("Peter", "Susan", "Edmund", "Lucy");

echo pos($people);

?>

a) Lucy

b) Peter

c) Susan

d) Edmund

Answer: b

78. What will be the output of the following PHP code?

<?php

$number = range(0, 5);

print_r ($number);
?>

a) Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 )

b) Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 )

c) Array ( [0] => 5 [1] => 5 [2] => 5 [3] => 5 [4] => 5 [5] => 5 )

d) Array ( [0] => 0 [5] => 5 )

Answer: a

79. What will be the output of the following PHP code?

<?php

$array = array("red", "green");

array_push($array, "blue", "yellow");

print_r($array);

?>

a) Array ( [0] => red [1] => green [2] => blue [3] => yellow )

b) Array ( [0] => blue [1] => yellow [2] => red [3] => green )

c) Array ( [0] => red [1] => green )

d) Array ( [0] => blue [1] => yellow )

Answer: a

80. What will be the output of the following PHP code?

<?php

$age = array("Harry" => "21", "Ron" => "19", "Malfoy" => "23");

ksort($age);

foreach($age as $x => $x_value)

echo "Key=" . $x . ", Value=" . $x_value;

echo "<br>";

?>

a)
Key = Harry, Value = 21

Key = Ron, Value = 21

Key = Malfoy, Value = 23

b)

Key = Harry, Value = 21

Key = Ron, Value = 19

Key = Malfoy, Value = 23

c)

Key = Harry, Value = 21

Key = Malfoy, Value = 23

Key = Ron, Value = 19

d)

Key = Ron, Value = 19

Key = Harry, Value = 21

Key = Malfoy, Value = 23

Answer: c

81. What will be the output of the following PHP code?

<?php

$cars = array("Volvo", "BMW", "Toyota");

echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";

?>

a) I like Volvo BMW and Toyota.

b) I like Volvo, BMW and Toyota)

c) I like Volvo, BMW and Toyota.


d) I like. Volvo.,. BMW. and. Toyota)

Answer: b

82. What will be the output of the following PHP code?

<?php

$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");

print_r(array_change_key_case($age, CASE_UPPER));

?>

a) Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )

b) Array ( [peter] => 35 [ben] => 37 [joe] => 43 )

c) Array ( [PETER] => 35 [BEN] => 37 [JOE] => 43 )

d) Array ( [PeTeR] => 35 [BeN] => 37 [Joe] => 43 )

Answer: c

83. What will be the output of the following PHP code?

<?php

$cars = array("Volvo", "BMW", "Toyota", "Honda", "Mercedes", "Opel");

print_r(array_chunk($cars, 2));

?>

a) Array ( [0] => Array ( [1] => Volvo [2] => BMW ) [1] => Array ( [1] => Toyota [2] => Honda ) [2] => Array
( [1] => Mercedes [2] => Opel ) )

b) Array ( [1] => Array ( [1] => Volvo [2] => BMW ) [2] => Array ( [1] => Toyota [2] => Honda ) [3] => Array
( [1] => Mercedes [2] => Opel ) )

c) Array ( [0] => Array ( [0] => Volvo [1] => Volvo ) [1] => Array ( [0] => BMW [1] => BMW ) [2] => Array (
[0] => Toyota [1] => Toyota ) )

d) Array ( [0] => Array ( [0] => Volvo [1] => BMW ) [1] => Array ( [0] => Toyota [1] => Honda ) [2] => Array
( [0] => Mercedes [1] => Opel ) )

Answer: d

84. What will be the output of the following PHP code?

<?php

$fname = array("Peter", "Ben", "Joe");


$age = array("35", "37", "43");

$c = array_combine($fname, $age);

print_r($c);

?>

a) Array ( Peter Ben Joe )

b) Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )

c) Array ( 35 37 43 )

d) Array ( “*Peter+ => 35” “*Ben+ => 37” “*Joe+ => 43” )

Answer: b

85. What will be the output of the following PHP code?

<?php

$a = array("A", "Cat", "Dog", "A", "Dog");

print_r(array_count_values($a));

?>

a) Array ( [A] => 2 [Cat] => 1 [Dog] => 2 )

b) Array ( [A] => 2 [Cat] => 2 [Dog] => 1 )

c) Array ( [A] => 1 [Cat] => 1 [Dog] => 2 )

d) Array ( [A] => 2 [Cat] => 1 [Dog] => 1)

Answer: a

86. What will be the output of the following PHP code?

<?php

$a1 = array("a"=>"red", "b"=>"green", "c"=>"blue", "d"=>"yellow");

$a2 = array("e"=>"red", "f"=>"green", "g"=>"blue");

$result = array_diff($a1, $a2);

print_r($result);

?>

a) Array ( [d] => yellow )

b) Array ( [c] => blue )


c) Array ( [a] => red )

d) Array ( [e] => yellow )

Answer: a

87. What will be the output of the following PHP code?

<?php

$a1 = array_fill(3, 4, "blue");

$b1 = array_fill(0, 1, "red");

print_r($a1);

echo "<br>";

print_r($b1);

?>

a)

Array ( [3] => blue [4] => blue)

Array ( [0] => red )

b)

Array ( [4] => blue [5] => blue [6] => blue)

Array ( [0] => red )

c)

Array ( [3] => blue [4] => blue [5] => blue [6] => blue )

Array ()

d)

Array ( [3] => blue [4] => blue [5] => blue [6] => blue )

Array ( [0] => red )

Answer: d
88. What will be the output of the following PHP code?

<?php

$a1 = array("red", "green");

$a2 = array("blue", "yellow");

print_r(array_merge($a1, $a2));

?>

a) Array ( [0] => red [1] => green)

b) Array ( [0] => blue [1] => yellow [2] => red [3] => green )

c) Array ( [0] => red [1] => green [2] => blue [3] => yellow )

d) Array ( [0] => blue [1] => yellow )

Answer: c

89. What will be the output of the following PHP code?

<?php

$a = array("a"=>"red", "b"=>"green", "c"=>"blue");

echo array_shift($a);

print_r ($a);

?>

a) green

b) red

c) redArray( [c] => green [c] => blue )

d) redArray( [b] => green [c] => blue )

Answer: d

90. What will be the output of the following PHP code?

<?php

$a = array("red", "green", "blue");

array_pop($a);

print_r($a);

?>
a) Array ( [0] => red [1] => green )

b) Array ( [0] => green [1] => blue )

c) Array ( [0] => red [1] => blue )

d) Array ( [0] => blue [1] => blue )

Answer: a

91. What will be the output of the following PHP code?

<?php

$fruits = array ("mango", "apple", "pear", "peach");

$fruits = array_flip($fruits);

echo ($fruits[0]);

?>

a) mango

b) error

c) peach

d) 0

Answer: b

92. Which of the functions is used to sort an array in descending order?

a) sort()

b) asort()

c) rsort()

d) dsort()

Answer: c

93. What will be the output of the following PHP code?

<?php

$fruits = array ("mango", "apple", "peach", "pear");

$fruits = asort ($fruits);

printr ($fruits);

?>
a) Array ( [1] => apple [0] => mango [2] => peach [3] => pear )

b) Array ( [0] => apple [1] => mango [2] => peach [3] => pear )

c) Error

d) Array ( [1] => apple [0] => mango [3] => peach [2] => pear )

Answer: c

94. What will be the output of the following PHP code?

<?php

$arr = array ("picture1.JPG", "picture2.jpg",

"Picture10.jpg", "picture20.jpg");

sort($arr);

print_r($arr);

?>

a) Array ( [0] => picture1.JPG [1] => Picture10.jpg [2] => picture2.jpg [3] => picture20.jpg )

b) Array ( [0] => picture1.JPG [1] => picture2.jpg [2] => Picture10.jpg [3] => picture20.jpg )

c) Array ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture2.jpg [3] => picture20.jpg )

d) Array ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture20.jpg [3] => picture2.jpg )

Answer: c

95. Which function should we use to sort the array in natural order?

a) dsort()

b) casesort()

c) natcasesort()

d) naturalsort()

Answer: c

96. What will be the output of the following PHP code?

<?php

$face = array ("A", "J", "Q", "K");

$number = array ("2","3","4", "5", "6", "7", "8", "9", "10");


$cards = array_merge ($face, $number);

print_r ($cards);

?>

a) Array ( [0] => A [1] => J [2] => Q [3] => K [4] => 2 [5] => 3 [6] => 4 [7] => 5 [8] => 6 [9] => 7 [10] => 8 [11]
=> 9 [12] => 10 )

b) Array ( [0] => A [1] => 2 [2] => J [3] => 3 [4] => Q [5] => 4 [6] => K [7] => 5 [8] => 6 [9] => 7 [10] => 8 [11]
=> 9 [12] => 10 )

c) Error

d) Array ( [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 6 [5] => 7 [6] => 8 [7] => 9 [8] => 10 [9] => A [10] => J
[11] => Q [12] => K )

Answer: a

97. What will be the output of the following PHP code?

<?php

$fruits = array ("apple", "mango", "peach", "pear",

"orange");

$subset = array_slice ($fruits, 2);

print_r ($subset);

?>

a) Array ( [0] => peach )

b) Array ( [0] => apple [1] => mango [2] => peach )

c) Array ( [0] => apple [1] => mango )

d) Array ( [0] => peach [1] => pear [2] => orange )

Answer: d

98. What will be the output of the following PHP code?

<?php

$fruits = array ("apple", "mango", "peach", "pear",

"orange");

$subset = array_splice ($fruits, 2);

print_r ($fruits);
?>

a) Error

b) Array ( [0] => apple [1] => mango [2] => peach )

c) Array ( [0] => apple [1] => mango )

d) Array ( [0] => pear [1] => orange )

Answer: c

99. What will be the output of the following PHP code?

<?php

$number = array ("4", "hello", 2);

echo (array_sum ($number));

?>

a) 4hello2

b) 4

c) 2

d) 6

Answer: d

100. What will be the output of the following PHP code?

<?php

$array1 = array ("KA", "LA", "CA", "MA", "TA");

$array2 = array ("KA", "IA", "CA", "GA", "TA");

$inter = array_intersect ($array1, $array2);

print_r ($inter);

?>

a) Array ( [0] => KA [1] => LA [2] => CA [3] => MA [4] => TA [5] => IA [6] => GA )

b) Array ( [0] => KA [2] => CA [4] => TA )

c) Array ( [1] => IA [3] => GA )

d) Array ( [1] => LA [3] => MA )

Answer: b
101. The practice of separating the user from the true inner workings of an application through well-
known interfaces is known as _________

a) Polymorphism

b) Inheritance

c) Encapsulation

d) Abstraction

Answer: c

102. Which of the following term originates from the Greek language that means “having multiple
forms,” defines OOP’s ability to redefine, a class’s characteristics?

a) Abstraction

b) Polymorphism

c) Inheritance

d) Differential

Answer: b

103. The practice of creating objects based on predefined classes is often referred to as
______________

a) class creation

b) object creation

c) object instantiation

d) class instantiation

Answer: d

104. Which one of the following property scopes is not supported by PHP?

a) friendly

b) final

c) public

d) static

Answer: a

105. Which one of the following can be used to instantiate an object in PHP assuming class name to be
Foo?
a) $obj = new $foo;

b) $obj = new foo;

c) $obj = new foo ();

d) obj = new foo ();

Answer: c

106. Which one of the following is the right way to define a constant?

a) constant PI = “3.1415”;

b) const $PI = “3.1415”;

c) constant PI = ‘3.1415’;

d) const PI = ‘3.1415’;

Answer: d

107. Which one of the following is the right way to call a class constant, given that the class is
mathFunction?

a) echo PI;

b) echo mathFunction->PI;

c) echo mathFunction::PI;

d) echo mathFunction=PI;

Answer: c

108. Which one of the following is the right way to invoke a method?

a) $object->methodName();

b) object->methodName();

c) object::methodName();

d) $object::methodName();

Answer: a

109. Which of the following is/are the right way to declare a method?

i) function functionName() { function body }

ii) scope function functionName() { function body }

iii) method methodName() { method body }


iv) scope method methodName() { method body }

a) Only ii)

b) Only iv)

c) i) and ii)

d) iii) and iv)

Answer: c

110. Which of the following method scopes is/are not supported by PHP?

i) private

ii) friendly

iii) static

iv) abstract

a) Only ii)

b) Only iv)

c) ii) and iv)

d) Only i)

Answer: a

111. Which method scope prevents a method from being overridden by a subclass?

a) Abstract

b) Protected

c) Final

d) Static

Answer: c

112. Which of the following statements is/are true about Constructors in PHP?

i) PHP 4 introduced class constructors.

ii) Constructors can accept parameters.

iii) Constructors can call class methods or other functions.

iv) Class constructors can call on other constructors.

a) ii)
b) ii) and iii)

c) i), ii), iii) and iv)

d) ii), iii) and iv)

Answer: c

113. PHP recognizes constructors by the name _________

a) classname()

b) _construct()

c) function _construct()

d) function __construct()

Answer: d

114. Which version of PHP introduced the instanceof keyword?

a) PHP 4

b) PHP 5

c) PHP 5.3

d) PHP 6

Answer: b

115. Which one of the following functions is used to determine whether a class exists?

a) exist()

b) exist_class()

c) class_exist()

d) __exist()

Answer: c

116. Which one of the following functions is used to determine object type?

a) obj_type()

b) type()

c) is_a()

d) is_obj()

Answer: c
117. Which one of the following keyword is used to inherit our subclass into a superclass?

a) extends

b) implements

c) inherit

d) include

Answer: a

118. In the following PHP code, what is/are the properties?

<?php

class Example

public $name;

function Sample()

echo "This is an example";

?>

a) echo “This is an example”;

b) public $name;

c) class Example

d) function sample()

Answer: b

119. Which keyword is used to refer to properties or methods within the class itself?

a) private

b) public

c) protected

d) $this

Answer: d
120. Which keyword allows class members (methods and properties) to be used without needing to
instantiate a new instance of the class?

a) protected

b) final

c) static

d) private

Answer: c

121. Which of the following advanced OOP features is/are not supported by PHP?

i) Method overloading

ii) Multiple Inheritance

iii) Namespaces

iv) Object Cloning

a) i)

b) ii)

c) i) and ii)

d) iii) and iv)

Answer: c

122. Which version of PHP introduced the advanced concepts of OOP?

a) PHP 4

b) PHP 5

c) PHP 5.3

d) PHP 6

Answer: b

123. Which one of the following is the right way to clone an object?

a) _clone(targetObject);

b) destinationObject = clone targetObject;

c) destinationObject = _clone(targetObject);

d) destinationObject = clone(targetObject);
Answer: b

124. The class from which the child class inherits is called ________

i) Child class

ii) Parent class

iii) Super class

iv) Base class

a) Only i)

b) ii), iii) and iv)

c) Only iii)

d) ii) and iv)

Answer: d

125. Which of the following is/are true for an abstract class?

i) Abstract classes in PHP are declared with the help of abstract keyword.

ii) A class is declare abstract by using the keyword implements.

iii) It is a class that really isn’t supposed to ever be instantiated but instead serves as a base class.

iv) Attempting to instantiate an abstract class results in an error.

a) Only i)

b) Only iii)

c) ii) and iv)

d) ii), iii) and iv)

Answer: a

126. If one intends to create a model that will be assumed by a number of closely related objects, which
class must be used?

a) Normal class

b) Static class

c) Abstract class

d) Interface

Answer: c
127. If your object must inherit behavior from a number of sources you must use a/an

a) Interface

b) Object

c) Abstract class

d) Static class

Answer: a

128. Which method is used to tweak an object’s cloning behavior?

a) clone()

b) __clone()

c) _clone

d) object_clone()

Answer: b

129. Which feature allows us to call more than one method or function of the class in single instruction?

a) Typecasting

b) Method Including

c) Method adding

d) Method chaining

Answer: d

130. Which magic method is used to implement overloading in PHP?

a) __call

b) __invoke

c) __wakeup

d) __unset

Answer: a

131. How many error levels are available in PHP?

a) 14

b) 15

c) 16
d) 17

Answer: c

132. What is the description of Error level E_ERROR?

a) Fatal run-time error

b) Near-fatal error

c) Compile-time error

d) Fatal Compile-time error

Answer: a

133. Which version of PHP introduced E_STRICT Error level?

a) PHP 4

b) PHP 5

c) PHP 5.2

d) PHP 5.3

Answer: b

134. Which character does the error_reporting directive use to represent the logical operator NOT?

a) /

b) !

c) ~

d) ^

Answer: c

135. Say you want to report error concerned about fatal run-time, fatal compile-time error and core
error which statement would you use?

a) error_reporting = E_ALL

b) error_reporting = E_ERROR | E_PARSE | E_CORE_ERROR

c) error_reporting = E_ERROR | E_COMPILE_WARNING | E_CORE_ERROR

d) error_reporting = E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR

Answer: d

136. Which version introduced the function error_get_last()?


a) PHP 4

b) PHP 5

c) PHP 5.2

d) PHP 5.3

Answer: c

137. Which of the following statements causes PHP to disregard repeated error messages that occur
within the same file and on the same line?

a) ignore_repeated_errors

b) ignore_repeat_error

c) repeatedly_ignore_error

d) repeated_error_ignore

Answer: a

138. Which function initializes the constants necessary for using the openlog(), clodelog(), and syslog()
functions?

a) define_variable()

b) define_log_variable()

c) log_variable()

d) define_syslog_variable()

Answer: d

139. Which logging option’s description is if an error occurs when writing to the syslog, send output to
the system console?

a) LOG_CONS

b) LOG_NDELAY

c) LOG_ODELAY

d) LOG_PERROR

Answer: a

140. Which function is responsible for sending a custom message to the system log?

a) systemlog()

b) syslog()
c) log_system()

d) sys_log()

Answer: b

141. Which version of PHP was added with Exception handling?

a) PHP 4

b) PHP 5

c) PHP 5.3

d) PHP 6

Answer: b

142. How many methods are available for the exception class?

a) 5

b) 6

c) 7

d) 8

Answer: c

143. Which version added the method getPrevious()?

a) PHP 4

b) PHP 5

c) PHP 5.1

d) PHP 5.3

Answer: d

144. Which of the following statements invoke the exception class?

a) throws new Exception();

b) throw new Exception();

c) new Exception();

d) new throws Exception();

Answer: b

145. Which one of the following is the right description for the method getMessage()?
a) Returns the message if it is passed to the constructor

b) Returns the message if it is passed to the class

c) Returns the message if it is passed to the file

d) Returns the message if it is passed to the object

Answer: a

146. You can extend the exception base class, but you cannot override any of the preceding methods
because the are declared as__________

a) protected

b) final

c) static

d) private

Answer: b

147. What does SPL stand for?

a) Standard PHP Library

b) Source PHP Library

c) Standard PHP List

d) Source PHP List

Answer: a

148. How many predefined exceptions does SPL provide access to?

a) 13

b) 14

c) 15

d) 16

Answer: a

149. Which of the following is/are an exception?

i) BadFunctionCallException

ii) BadMethodCallException

iii) LogicException
iv) DomainException

a) Only ii)

b) Only iii)

c) i), ii), iii) and iv)

d) Only iv)

Answer: c

150. Which of the following is/are an exception?

i) OutOfBoundException

ii) OutOfRangeException

iii) OverflowException

iv) UnderflowException

a) i)

b) i) and iii)

c) i) and ii)

d) i), ii), iii) and iv)

Answer: d

151. Which of the following is/are an external data?

i) Cookies

ii) Input data from a form

iii) Server Variables

iv) Web services data

a) Only ii)

b) ii) and iii)

c) Only iii)

d) i), ii), iii) and iv)

Answer: d

152. How many types of filtering are present in PHP?

a) 3
b) 2

c) 4

d) None

Answer: b

153. Which one of the following filter is used to filter several variables with the same or different filters?

a) filter_var_array()

b) filter_var()

c) filter_input

d) filter_input_array

Answer: a

154. What will be the output of the following PHP code?

<?php

$num = "123";

if (!filter_var($num, FILTER_VALIDATE_INT))

echo("Integer is not valid");

else

echo("Integer is valid");

?>

a) No output is returned

b) Integer is not valid

c) Integer is valid

d) Error

Answer: c

155. Which one of the following does not describe a validating filter?

a) Are used to allow or disallow specific characters in a string

b) Are used to validate user input

c) Strict format rules

d) Returns the expected type on success or FALSE on failure


Answer: a

156. What will be the output of the following PHP code?

<?php

$var=300;

$int_options = array("options"=>array ("min_range"=>0, "max_range"=>256));

if (!filter_var($var, FILTER_VALIDATE_INT, $int_options))

echo("Integer is not valid");

else

echo("Integer is valid");

?>

a) No output is returned

b) Integer is not valid

c) Integer is valid

d) Error

Answer: b

157. If the input variable is a string like this “http://www.saåånfoøøundry.com/”, the $url variable after
the sanitizing will look like?

a) http://www.saåånfoøøundry.com/

b) http://www.saaanfoooundry.com/

c) http://www.saånfoøundry.com/

d) https://www.sanfoundry.com/

Answer: d

158. Which one of the following filter checks if the variable of the specified type exists?

a) filter_has_var

b) filter_var

c) filter_id

d) filter_var_array

Answer: a
159. What will be the output of the following PHP code?

<?php

$value = 'car';

$result = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);

?>

a) FALSE

b) TRUE

c) NULL

d) ERROR

Answer: c

160. What will be the output of the following PHP code?

<?php

function convertSpace($string)

return str_replace("_", " ", $string);

$string = "Peter_is_a_great_guy!";

echo filter_var($string, FILTER_CALLBACK, array("options"=>"convertSpace"));

?>

a) Peter_is_a_great_guy!

b) Peterisagreatguy!

c) Peter is a great guy!

d) Error

Answer: c

161. PHP has long supported two regular expression implementations known as _______ and _______

i) Perl

ii) PEAR

iii) Pearl
iv) POSIX

a) i) and ii)

b) ii) and iv)

c) i) and iv)

d) ii) and iii)

Answer: c

162. Which one of the following regular expression matches any string containing zero or one p?

a) p+

b) p*

c) P?

d) p#

Answer: c

163. [:alpha:] can also be specified as ________

a) [A-Za-z0-9]

b) [A-za-z]

c) [A-z]

d) [a-z]

Answer: b

164. How many functions does PHP offer for searching strings using POSIX style regular expression?

a) 7

b) 8

c) 9

d) 10

Answer: a

165. What will be the output of the following PHP code?

<?php

$username = "jasoN";

if (ereg("([^a-z])",$username))
echo "Username must be all lowercase!";

else

echo "Username is all lowercase!";

?>

a) Error

b) Username must be all lowercase!

c) Username is all lowercase!

d) No Output is returned

Answer: b

166. POSIX implementation was deprecated in which version of PHP?

a) PHP 4

b) PHP 5

c) PHP 5.2

d) PHP 5.3

Answer: d

167. POSIX stands for ____________

a) Portable Operating System Interface for Unix

b) Portable Operating System Interface for Linux

c) Portative Operating System Interface for Unix

d) Portative Operating System Interface for Linux

Answer: a

168. What will be the output of the following PHP code?

<?php

$text = "this is\tsome text that\nwe might like to parse.";

print_r(split("[\n\t]",$text));

?>

a) this is some text that we might like to parse.

b) Array ( [0] => some text that [1] => we might like to parse. )
c) Array ( [0] => this is [1] => some text that [2] => we might like to parse. )

d) [0] => this is [1] => some text that [2] => we might like to parse.

Answer: d

169. Which of the following would be a potential match for the Perl-based regular expression /fo{2,4}/?

i) fol

ii) fool

iii) fooool

iv) fooooool

a) Only i)

b) ii) and iii)

c) i), iii) and iv)

d) i) and iv) Answer: b

170. Which among the following is/are not a metacharacter?

i) \a

ii) \A

iii) \b

iv) \B

a) Only i)

b) i) and iii)

c) ii), iii) and iv)

d) ii) and iv)

Answer: a

171. How many functions does PHP offer for searching and modifying strings using Perl-compatible
regular expressions.

a) 7

b) 8

c) 9

d) 10
Answer: b

172. What will be the output of the following PHP code?

<?php

$foods = array("pasta", "steak", "fish", "potatoes");

$food = preg_grep("/^s/", $foods);

print_r($food);

?>

a) Array ( [0] => pasta [1] => steak [2] => fish [3] => potatoes )

b) Array ( [3] => potatoes )

c) Array ( [1] => steak )

d) Array ( [0] => potatoes )

Answer: c

173. Say we have two compare two strings which of the following function/functions can you use?

i) strcmp()

ii) strcasecmp()

iii) strspn()

iv) strcspn()

a) i) and ii)

b) iii) and iv)

c) only i)

d) i), ii), iii) and iv)

Answer: d

174. Which one of the following functions will convert a string to all uppercase?

a) strtoupper()

b) uppercase()

c) str_uppercase()

d) struppercase()

Answer: a
175. What will be the output of the following PHP code?

<?php

$title = "O'malley wins the heavyweight championship!";

echo ucwords($title);

?>

a) O’Malley Wins The Heavyweight Championship!

b) O’malley Wins The Heavyweight Championship!

c) O’Malley wins the heavyweight championship!

d) o’malley wins the heavyweight championship!

Answer: a

176. What will be the output of the following PHP code?

<?php

echo str_pad("Salad", 5)." is good.";

?>

a) SaladSaladSaladSaladSalad is good

b) is good SaladSaladSaladSaladSalad

c) is good Salad

d) Salad is good

Answer: d

177. Which one of the following functions can be used to concatenate array elements to form a single
delimited string?

a) explode()

b) implode()

c) concat()

d) concatenate()

Answer: b

178. Which one of the following functions finds the last occurrence of a string, returning its numerical
position?
a) strlastpos()

b) strpos()

c) strlast()

d) strrpos()

Answer: d

179. What will be the output of the following PHP code?

<?php

$author = "nachiketh@example.com";

$author = str_replace("a","@",$author);

echo "Contact the author of this article at $author.";

?>

a) Contact the author of this article at nachiketh@ex@mple.com

b) Cont@ct the @uthor of this @rticle @t n@chiketh@ex@mple.com

c) Contact the author of this article at n@chiketh@ex@mple.com

d) Error

Answer: c

180. What will be the output of the following PHP code?

<?php

$url = "nachiketh@example.com";

echo ltrim(strstr($url, "@"),"@");

?>

a) nachiketh@example.com

b) nachiketh

c) nachiketh@

d) example.com

Answer: d

181. The filesize() function returns the file size in ___________

a) bits
b) bytes

c) kilobytes

d) gigabytes

Answer: b

182. Which one of the following PHP function is used to determine a file’s last access time?

a) fileltime()

b) filectime()

c) fileatime()

d) filetime()

Answer: c

183. Which one of the following function is capable of reading a file into an array?

a) file()

b) arrfile()

c) arr_file()

d) file_arr()

Answer: a

184. Which one of the following function is capable of reading a file into a string variable?

a) file_contents()

b) file_get_contents()

c) file_content()

d) file_get_content()

Answer: b

185. Which one of the following function is capable of reading a specific number of characters from a
file?

a) fgets()

b) fget()

c) fileget()

d) filegets()
Answer: a

186. Which one of the following function operates similarly to fgets(), except that it also strips any HTML
and PHP tags form the input?

a) fgetsh()

b) fgetsp()

c) fgetsa()

d) fgetss()

Answer: d

187. Which one of the following function outputs the contents of a string variable to the specified
resource?

a) filewrite()

b) fwrite()

c) filewrites()

d) fwrites()

Answer: b

188. Which function sets the file filename last-modified and last-accessed times?

a) sets()

b) set()

c) touch()

d) touched()

Answer: c

189. Which function is useful when you want to output the executed command result?

a) out_cmm()

b) out_system()

c) cmm()

d) system()

Answer: d

190. Which one of the following function reads a directory into an Array?
a) scandir()

b) readdir()

c) scandirectory()

d) readdirectory()

Answer: a

191. What will be the output of the following PHP code?

<?php

echo (checkdate(4,31,2010) ? 'Valid' : 'Invalid');

?>

a) TRUE

b) FALSE

c) Valid

d) Invalid

Answer: d

192. The date() function returns ___ representation of the current date and/or time.

a) Integer

b) String

c) Boolean

d) Float

Answer: b

193. Which one of the following format parameter can be used to identify timezone?

a) T

b) N

c) E

d) I

Answer: c

194. If the format is F then which one of the following will be returned?

a) Complete text representation of month


b) Day of month, with leading zero

c) Daylight saving time

d) Day of month, without zeros

Answer: a

195. What will be the output of the following code? (If say date is 22/06/2013.)

<?php

echo "Today is ".date("F d, Y");

?>

a) Today is 22 June, 2013

b) Today is 22-06-2013

c) Today is 06-22-2013

d) Today is June 22, 2013

Answer: d

196. Which one of the following function is useful for producing a timestamp based on a given date and
time?

a) time()

b) mktime()

c) mrtime()

d) mtime()

Answer: b

197. Which function displays the web page’s most recent modification date?

a) lastmod()

b) getlastmod()

c) last_mod()

d) get_last_mod()

Answer: b

198. What will be the output of the following PHP code? (If say date is 22/06/2013.)

<?php
printf( date("t") );

?>

a) 30

b) 22

c) JUNE

d) 2013

Answer: a

199. Suppose you want to calculate the date 45 days from the present date which one of the following
statement will you use?

a) totime(“+45”)

b) totime(“+45 days”)

c) strtotime(“+45 days”)

d) strtotime(“-45 days”)

Answer: c

200. To create an object and set the date to JUNE 22, 2013, which one of the following statement should
be executed?

a) $date = Date(“22 JUNE 2013”)

b) $date = new Date(“JUNE 22 2013”)

c) $date = DateTime(“22 JUNE 2013”)

d) $date = new DateTime(“22 JUNE 2013”)

Answer: d

201. How many methods does the DateTime class have?

a) 8

b) 9

c) 10

d) 11

Answer: b

202. How many constants does the DateTime class have?


a) 8

b) 9

c) 10

d) 11

Answer: d

203. Which method is simply an object-oriented version of date()?

a) DateTime::format()

b) DateTime::modify()

c) DateTime::setTime()

d) DateTime::setDate()

Answer: a

204. Which of the following is the right way to use the DateTime class?

a) $date = get_Class(DateTime);

b) $date = class DateTime;

c) $date = new DateTime();

d) $date = new class DateTime();

Answer: c

205. What will be the output of the following PHP code if date is 24/02/2008?

<?php

$date = new DateTime();

echo $date->format('l,F,js,Y');

?>

a) Sunday, February 24th 2008

b) Sunday, 02 24 2008

c) Sunday, 24 02 2008

d) Sunday, 24th February 2008

Answer: a

206. Which of the following statements can be used to set the time zone in individual scripts?
a) date_set_timezone(‘Europe/London’);

b) date_default_timezone_set(‘Europe/London’);

c) date_set_default_timezone(‘Europe/London’);

d) date_default_timezone(‘Europe/London’);

Answer: b

207. Which of the following DateTimeZone classes are static?

i) listAbbreviations()

ii) getName()

iii) getOffset()

iv) listIdentifiers()

a) Only i)

b) Only ii)

c) i) and iv)

d) iii) and iv)

Answer: c

208. Which of the following DateTimeZone classes are non-static?

i) _construct()

ii) getName()

iii) getOffset()

iv) getTransitions()

a) Only i)

b) Only ii)

c) i), ii), iii) and iv)

d) iii) and iv)

Answer: c

209. Which of the following statements can be used to add two months to the existing date?

a) $date->modify(‘+2 months’);

b) $date = modify(‘+2 months’);


c) $date = modify(‘2+ months’);

d) $date->modify(‘2+ months’);

Answer: a

210. Which method enables you to calculate whether daylight saving time is in force at a specific date
and time?

a) getOffset()

b) getTranitions()

c) ISODate()

d) savingTime()

Answer: b

211. Which two predefined variables are used to retrieve information from forms?

a) $GET & $SET

b) $_GET & $_SET

c) $__GET & $__SET

d) GET & SET

Answer: b

212. The attack which involves the insertion of malicious code into a page frequented by other users is
known as _______________

a) basic sql injection

b) advanced sql injection

c) cross-site scripting

d) scripting

Answer: c

213. When you use the $_GET variable to collect data, the data is visible to ___________

a) none

b) only you

c) everyone

d) selected few
Answer: c

214. When you use the $_POST variable to collect data, the data is visible to ___________

a) none

b) only you

c) everyone

d) selected few

Answer: b

215. Which variable is used to collect form data sent with both the GET and POST methods?

a) $BOTH

b) $_BOTH

c) $REQUEST

d) $_REQUEST

Answer: d

216. Which one of the following should not be used while sending passwords or other sensitive
information?

a) GET

b) POST

c) REQUEST

d) NEXT

Answer: a

217. Which function is used to remove all HTML tags from a string passed to a form?

a) remove_tags()

b) strip_tags()

c) tags_strip()

d) tags_remove()

Answer: b

218. What will be the value of the variable $input in the following PHP code?

<?php
$input = "Swapna<td>Lawrence</td>you are really<i>pretty</i>!";

$input = strip_tags($input,"<i></i>");

echo $input;

?>

a) Swapna Lawrence you are really pretty!

b) Swapna <td>Lawrence</td> you are really<i>pretty</i>!

c) Swapna <td>Lawrence</td> you are really pretty!

d) Swapna Lawrence you are really<i>pretty</i>!

Answer: d

219. To validate an email address, which flag is to be passed to the function filter_var()?

a) FILTER_VALIDATE_EMAIL

b) FILTER_VALIDATE_MAIL

c) VALIDATE_EMAIL

d) VALIDATE_MAIL

Answer: a

220. How many validation filters like FILTER_VALIDATE_EMAIL are currently available?

a) 5

b) 6

c) 7

d) 8

Answer: c

221. How many predefined variables does PHP use to authenticate a user?

a) 1

b) 2

c) 3

d) 4

Answer: b

222. Which of the following variables does PHP use to authenticate a user?
i) $_SERVER['PHP_AUTH_USER'].

ii) $_SERVER['PHP_AUTH_USERS'].

iii) $_SERVER['PHP_AUTH_PU'].

iv) $_SERVER['PHP_AUTH_PW'].

a) i) and ii)

b) ii) and iv)

c) i) and iv)

d) ii) and iii)

Answer: c

223. Which of the following PHP function is commonly used when handling authentication via PHP?

i) header()

ii) footer()

iii) inset()

iv) isset()

a) i) and iv)

b) ii) and iv)

c) ii) and iii)

d) i) and iii)

Answer: a

224. Which function is used to verify whether a variable contains a value?

a) header()

b) footer()

c) inset()

d) isset()

Answer: d

225. Which of the following are types of PHP authentication implementation methodologies?

i) Hard-coding a login pair directly into the script

ii) File-based authentication


iii) Data-based authentication

iv) PEAR'S HTTP authentication

a) ii) and iii)

b) i) and iv)

c) i), ii), iii) and iv)

d) Only iv)

Answer: c

226. In which authentication method does changing the username or password can be done only by
entering the code and making the manual adjustment.

a) Hard-coding a login pair directly into the script

b) File-based authentication

c) Data-based authentication

d) PEAR’S HTTP authentication

Answer: a

227. The authenticationFile.txt, the file which stores username and password should be stored ___ the
server document root.

a) Inside

b) Outside

c) Within

d) None of the mentioned

Answer: b

228. Which function is used to split a string into a series of substrings, with each string boundary is
determined by a specific separator?

a) break()

b) divide()

c) explode()

d) md5()

Answer: c

229. In which of the following situations does file-based authentication become inconvenient.
i) small list

ii) large number of user

iii) users are being regularly added

iv) static authentication

a) i) and iv)

b) i) and iii)

c) ii) and iii)

d) ii) and iv)

Answer: c

230. Which is the most powerful authentication method among the four?

a) Hard-coding a login pair directly into the script

b) File-based authentication

c) Data-based authentication

d) PEAR’S HTTP authentication

Answer: c

231. Which directive determines whether PHP scripts on the server can accept file uploads?

a) file_uploads

b) file_upload

c) file_input

d) file_intake

Answer: a

232. Which of the following directive determines the maximum amount of time that a PHP script will
spend attempting to parse input before registering a fatal error?

a) max_take_time

b) max_intake_time

c) max_input_time

d) max_parse_time

Answer: c
233. What is the default value of max_input_time directive?

a) 30 seconds

b) 60 seconds

c) 120 seconds

d) 1 second

Answer: b

234. Since which version of PHP was the directive max_file_limit available.

a) PHP 5.2.1

b) PHP 5.2.2

c) PHP 5.2.12

d) PHP 5.2.21

Answer: c

235. What is the default value of the directive max_file_limit?

a) 10 files

b) 15 files

c) 20 files

d) 25 files

Answer: c

236. Which directive sets a maximum allowable amount of memory in megabytes that a script can
allow?

a) max_size

b) post_max_size

c) max_memory_limit

d) memory_limit

Answer: d

237. If you want to temporarily store uploaded files in the /tmp/phpuploads/ directory, which one of the
following statement will you use?

a) upload_tmp_dir “/tmp/phpuploads/ directory”


b) upload_dir “/tmp/phpuploads/ directory”

c) upload_temp_dir “/tmp/phpuploads/ directory”

d) upload_temp_director “/tmp/phpuploads/ directory”

Answer: a

238. Which superglobal stores a variety of information pertinent to a file uploaded to the server via a
PHP script?

a) $_FILE Array

b) $_FILES Array

c) $_FILES_UPLOADED Array

d) $_FILE_UPLOADED Array

Answer: b

239. How many items are available in the $_FILES array?

a) 2

b) 3

c) 4

d) 5

Answer: d

240. Which function is used to determine whether a file was uploaded?

a) is_file_uploaded()

b) is_uploaded_file()

c) file_uploaded(“filename”)

d) uploaded_file(“filename”)

Answer: b

241. What is the full form of DNS?

a) Digital Network System

b) Domain Network System

c) Digital Name Systmem

d) Domain Name System


Answer: d

242. Which one of the following function checks for the existence of DNS records?

a) checkdns()

b) checkdnsr()

c) checkdnsrr()

d) checkdnsa()

Answer: c

243. Which one of the following function is used to return an array consisting of various DNS resource
records pertinent to a specific domain?

a) dns_get_record()

b) dns_record()

c) dnsrr_get_record()

d) dnsrr_record()

Answer: a

244. Which one of the following function is used to retrieve the MX records for the domain specified by
hostname?

a) getmx()

b) retrieve_mx()

c) getmxrr()

d) retrieve_mxrr()

Answer: c

245. What is the default port number of HTTPs?

a) 70

b) 80

c) 90

d) 100

Answer: b

246. Which one of the following function returns the port number of a specified service?
a) getportname()

b) getservername()

c) getserverbyname()

d) getservbyname()

Answer: d

247. Which one of the following statements can be used to establish port 80 connection with
www.nachi.com?

a) fsockopen(“www.nachi.com”, 80);

b) sockopen(80,”www.nachi.com”);

c) fsockopen(80,”www.nachi.com”);

d) sockopen(“www.nachi.com”, 80);

Answer: a

248. Which one of the following function is used to send an email using PHP script?

a) mail_send()

b) send_mail()

c) mailrr()

d) mail() Answer: d

249. How many configuration directives pertinent to PHP’s mail function are available?

a) 4

b) 5

c) 6

d) 7

Answer: b

250. Which of the following statements is used to add an attachment to the mail?

a) $mimemail->attachment(‘attachment.pdf’);

b) $mimemail=>attachment(‘attachment.pdf’);

c) $mimemail->addAttachment(‘attachment.pdf’);

d) $mimemail=>addAttachment(‘attachment.pdf’);
Answer: c

251. Which one of the following is the very first task executed by a session enabled page?

a) Delete the previous session

b) Start a new session

c) Check whether a valid session exists

d) Handle the session

Answer: c

252. How many ways can a session data be stored?

a) 3

b) 4

c) 5

d) 6

Answer: b

253. Which directive determines how the session information will be stored?

a) save_data

b) session.save

c) session.save_data

d) session.save_handler

Answer: d

254. Which one of the following is the default PHP session name?

a) PHPSESSID

b) PHPSESID

c) PHPSESSIONID

d) PHPIDSESS

Answer: a

255. If session.use_cookie is set to 0, this results in use of _____________

a) Session

b) Cookie
c) URL rewriting

d) Nothing happens

Answer: c

256. If the directive session.cookie_lifetime is set to 3600, the cookie will live until ____________

a) 3600 sec

b) 3600 min

c) 3600 hrs

d) the browser is restarted

Answer: a

257. Neglecting to set which of the following cookie will result in the cookie’s domain being set to the
host name of the server which generated it.

a) session.domain

b) session.path

c) session.cookie_path

d) session.cookie_domain

Answer: d

258. What is the default number of seconds that cached session pages are made available before the
new pages are created?

a) 360

b) 180

c) 3600

d) 1800

Answer: b

259. What is the default time(in seconds) for which session data is considered valid?

a) 1800

b) 3600

c) 1440

d) 1540
Answer: c

260. Which one of the following function is used to start a session?

a) start_session()

b) session_start()

c) session_begin()

d) begin_session()

Answer: b

261. Which function is used to erase all session variables stored in the current session?

a) session_destroy()

b) session_change()

c) session_remove()

d) session_unset()

Answer: d

262. What will the function session_id() return is no parameter is passed?

a) Current Session Identification Number

b) Previous Session Identification Number

c) Last Session Identification Number

d) Error

Answer: a

263. Which one of the following statements should you use to set the session username to Nachi?

a) $SESSION*‘username’+ = “Nachi”;

b) $_SESSION*‘username’+ = “Nachi”;

c) session_start(“nachi”);

d) $SESSION_START*“username”+ = “Nachi”;

Answer: b

264. What will be the output of the following PHP code? (Say your previous session username was
nachi.)

unset($_SESSION['username']);
printf("Username now set to: %s", $_SESSION['username']);

a) Username now set to: nachi

b) Username now set to: System

c) Username now set to:

d) Error

Answer: c

265. An attacker somehow obtains an unsuspecting user’s SID and then using it to impersonate the user
in order to gain potentially sensitive information. This attack is known as __________

a) session-fixation

b) session-fixing

c) session-hijack

d) session-copy

Answer: a

266. Which parameter determines whether the old session file will also be deleted when the session ID
is regenerated?

a) delete_old_file

b) delete_old_session

c) delete_old_session_file

d) delete_session_file

Answer: b

267. Which function effectively deletes all sessions that have expired?

a) session_delete()

b) session_destroy()

c) session_garbage_collect()

d) SessionHandler::gc

Answer: d

268. Which function is used to transform PHP’s session-handler behavior into that defined by your
custom handler?

a) session_set_save()
b) session_set_save_handler()

c) Session_handler()

d) session_save_handler()

Answer: b

269. The session_start() function must appear _________

a) after the html tag

b) after the body tag

c) before the body tag

d) before the html tag

Answer: d

260. What is the return type of session_set_save_handler() function?

a) boolean

b) integer

c) float

d) character

Answer: a

261. Which one of the following statements should be used to disable just the fopen(), and file()
functions?

a) disable_functions = fopen(), file()

b) disable_functions = fopen, file

c) functions_disable = fopen(), file()

d) functions_disable = fopen, file

Answer: b

262. Which one of the following statements should be used to disable the use of two classes
administrator and janitor?

a) disable_classes = “administrator, janitor”

b) disable_classes = class administrator, class janitor

c) disable_classes = class “administrator”, class “janitor”


d) disable_class = class “administrator”, class “janitor”

Answer: a

263. What is the default value of max_execution_time directive? This directive specifies how many
seconds a script can execute before being terminated.

a) 10

b) 20

c) 30

d) 40

Answer: c

264. The memory_limit is only applicable if ________ is enabled when you configure PHP.

a) –enable-limit

b) -enable-memory-limit

c) –enable-memory-limit

d) -memory-limit

Answer: c

265. Suppose all web material is located within the directory /home/www. To prevent users from
viewing and manipulating files such as /etc/password, which one of the following statements should you
use?

a) open_dir = “/home/www/”

b) open_dir = /home/www/

c) open_basedir = /home/www/

d) open_basedir = “/home/www/”

Answer: d

266. Which Apache directive outputs Apache’s server version, server name, port and compile-in
modules?

a) ServerSignature

b) ServerName

c) ServerDetails

d) ServerInfo
Answer: a

267. Which directive determines which degree of server details is provided if the ServerSignature
directive is enabled?

a) ServerAddons

b) ServerExtra

c) ServerTokens

d) ServerDetails

Answer: c

268. Which directive should we disable to obscure the fact that PHP is being used on our server?

a) show_php

b) expose_php

c) print_php

d) info_php

Answer: b

269. Say I want to change the extension of a PHP file, which of the following statements should I edit to
change from .php to .html in the httpd.conf file?

a) AddType application/x-httpd-php .php

b) AddType application/x-httpd-php .asp

c) AddType application/x-httpd-asp .php

d) AddType application/x-httpd-asp .asp

Answer: a

270. The developers of PHP deprecated the safe mode feature as of which PHP version.

a) PHP 5.1.0

b) PHP 5.2.0

c) PHP 5.3.0

d) PHP 5.3.1 Answer: c

271. What will be the output of the following PHP code?


<?php

$number = array(0,1,two,three,four,5);

$num = preg_grep("/[0-5]/", $number);

print_r($num);

?>

a) Array([0]=>0 [1]=>1 [2]=>two [3]=>three [4]=>four [5]=>5)

b) Array([2]=>two [3]=>three [4]=>four)

c) Array([1]=> 1)

d) Array([0]=>0 [1]=>1 [5]=>5)

Answer: d

272. What will be the output if we replace the line $num = preg_grep(“/*0-5+/”, $number); with $num =
preg_grep(“/*0-5+/”, $number, PREG_GREP_INVERT);?

a) Array([0]=>0 [1]=>1 [2]=>two [3]=>three [4]=>four [5]=>5)

b) Array([2]=>two [3]=>three [4]=>four)

c) Array([1]=> 1)

d) Array([0]=>0 [5]=>5)

Answer: b

273. Which one of the following functions are used to search a string?

a) preg_match

b) preg_search

c) preg_find

d) preg_found

Answer: a

274. What will be the output of the following PHP code?

<?php

$name = "What is your name?";

if (preg_match("/name/"),$name)

echo "My name is Will Pitt ";


else

echo "My name is not Will Pitt ";

if (preg_match("/are/"))

echo "I am great";

else

echo "I am not great";

?>

a) My name is Will Pitt I am great

b) My name is not Will Pitt I am great

c) My name is Will Pitt I am not great

d) My name is not Will Pitt I am not great

Answer: c

275. Which one of the following preg PHP function is used to do a find and replace on a string or an
array?

a) preg_replace()

b) preg_find()

c) preg_find_replace()

d) preg_findre()

Answer: a

276. What will be the output of the following PHP code?

<?php

$str = "Hello! My name is Cameron Fox. Coffee?";

$find = array('/is/','/coffee/');

$replace = array('/was/','/tea/');

echo preg_replace ($find, $replace, $str);

?>

a) Hello! My name was Cameron Fox. tea?

b) Hello! My name is Cameron Fox. tea?


c) Hello! My name is Cameron Fox. Coffee?

d) Hello! My name was Cameron Fox. Coffee?

Answer: d

277. Which one of the following preg PHP functions is used to take a string, and put it in an array?

a) preg_destroy()

b) preg_split()

c) preg_unchain()

d) preg_divide()

Answer: b

278. What will be the output of the following PHP code?

<?php

$line = "You like dogs. I hate dogs. We should marry.";

$sen = preg_split('/\./', $line);

print_r($sen);

?>

a) You like dogs. I hate dogs. We should marry.

b) Array([0]=>You like dogs. I hate dogs. We should marry.)

c) Array([0]=>You like dogs. [1]=>I hate dogs. [2]=>We should marry.)

d) Error

Answer: c

279. Which one of the following is not a preg PHP function?

a) preg_match

b) preg_match_all

c) preg_matchall

d) preg_split

Answer: c

280. Parameter flags was added in which version of PHP?

a) PHP 4.0
b) PHP 4.1

c) PHP 4.2

d) PHP 4.3

Answer: d

281. Which one of the following databases has PHP supported almost since the beginning?

a) Oracle Database

b) SQL

c) SQL+

d) MySQL

Answer: d

282. The updated MySQL extension released with PHP 5 is typically referred to as _______________

a) MySQL

b) mysql

c) mysqli

d) mysqly

Answer: c

283. Which one of the following lines need to be uncommented or added in the php.ini file so as to
enable mysqli extension?

a) extension=php_mysqli.dll

b) extension=mysql.dll

c) extension=php_mysqli.dl

d) extension=mysqli.dl

Answer: a

284. In which version of PHP was MySQL Native Driver(also known as mysqlnd) introduced?

a) PHP 5.0

b) PHP 5.1

c) PHP 5.2

d) PHP 5.3
Answer: d

285. Which one of the following statements is used to create a table?

a) CREATE TABLE table_name (column_name column_type);

b) CREATE table_name (column_type column_name);

c) CREATE table_name (column_name column_type);

d) CREATE TABLE table_name (column_type column_name);

Answer: a

286. Which one of the following statements instantiates the mysqli class?

a) mysqli = new mysqli()

b) $mysqli = new mysqli()

c) $mysqli->new.mysqli()

d) mysqli->new.mysqli()

Answer: b

287.Which one of the following statements can be used to select the database?

a) $mysqli=select_db('databasename');

b) mysqli=select_db('databasename');

c) mysqli->select_db('databasename');

d) $mysqli->select_db('databasename');

Answer: d

288. Which one of the following methods can be used to diagnose and display information about a
MySQL connection error?

a) connect_errno()

b) connect_error()

c) mysqli_connect_errno()

d) mysqli_connect_error()

Answer: c

289. Which method returns the error code generated from the execution of the last MySQL function?

a) errno()
b) errnumber()

c) errorno()

d) errornumber()

Answer: a

290. If there is no error, then what will the error() method return?

a) TRUE

b) FALSE

c) Empty String

d) 0

Answer: c

291. Which one of the following statements should be used to include a file?

a) #include ‘filename’;

b) include ‘filename’;

c) @include ‘filename’;

d) #include <filename>;

Answer: b

292. Which one of the following methods is responsible for sending the query to the database?

a) query()

b) send_query()

c) sendquery()

d) mysqli_query()

Answer: d

293. Which one of the following methods recuperates any memory consumed by a result set?

a) destroy()

b) mysqli_free_result()

c) alloc()

d) free()

Answer: b
294. Which of the methods are used to manage result sets using both associative and indexed arrays?

a) get_array() and get_row()

b) get_array() and get_column()

c) fetch_array() and fetch_row()

d) mysqli_fetch_array() and mysqli_fetch_row()

Answer: d

295. Which one of the following method is used to retrieve the number of rows affected by an INSERT,
UPDATE, or DELETE query?

a) num_rows()

b) affected_rows()

c) changed_rows()

d) mysqli_affected_rows()

Answer: d

296. Which version of MySQL introduced the prepared statements?

a) MySQL 4.0

b) MySQL 4.1

c) MySQL 4.2

d) MySQL 4.3

Answer: b

297. Which of the following methods is used to execute the statement after the parameters have been
bound?

a) bind_param()

b) bind_result()

c) bound_param()

d) bound_result()

Answer: a

298. Which one of the following methods is used to recuperating prepared statements resources?

a) end()
b) finish()

c) mysqli_close()

d) close()

Answer: c

299. Which method retrieves each row from the prepared statement result and assigns the fields to the
bound results?

a) get_row()

b) fetch_row()

c) fetch()

d) mysqli_fetch_row()

Answer: d

300. Which method rolls back the present transaction?

a) commit()

b) undo()

c) mysqli_rollback()

d) rollback()

Answer: c

301. Which one of the following is not a valid class name?

a) ShopProduct

b) Shopproduct

c) Shopproduct1

d) 1shopproduct

Answer: d

302. Fill in the blank with the best option. An Object is a/an ________ of a class.

a) type

b) prototype

c) instance

d) object
Answer: c

303. There are two objects-

$product1 = new Shop();

$product2 = new Shop();

Which one of the following statements is right about them?

a) $product1 and $product2 are same objects of the same type generated from a single class

b) $product1 and $product2 are different objects of the same type generated from a single class

c) $product1 and $product2 are same objects of the different type generated from a single class

d) $product1 and $product2 are different objects of the different type generated from a single class

Answer: b

304. Which version of PHP introduced the visibility keywords i.e public, private, and protected?

a) PHP 4

b) PHP 5

c) PHP 5.1

d) PHP 5.3

Answer: b

305. Which characters is used to access property variables on an object-by-object basis?

a) ::

b) =

c) ->

d) .

Answer: c

306. Code that uses a class, function, or method is often described as the ____________

a) client code

b) user code

c) object code

d) class code

Answer: a
307. Which keyword precedes a method name?

a) method

b) function

c) public

d) protected

Answer: b

308. If you omit the visibility keyword in your method declaration, by default the method will be
declared as ____________

a) public

b) private

c) protected

d) friendly

Answer: a

309. Which function is used to determine whether the variable’s value is either TRUE or FALSE?

a) boolean()

b) is_boolean()

c) bool()

d) is_bool()

Answer: d

310. What will be the output of the following PHP code?

<?php

class ShopProductWriter

public function write( $shopProduct )

$str = "{$shopProduct->title}: " .$shopProduct->getProducer() ." ({$shopProduct->price})\n";

print $str;

}
}

$product1 = new ShopProduct( "My Antonia", "Willa", "Cather", 5.99 );

$writer = new ShopProductWriter();

$writer->write( $product1 );

?>

a) Error

b) Cather: Willa My Antonia (5.99)

c) Willa: Cather My Antonia (5.99)

d) My Antonia: Willa Cather (5.99)

Answer: d

311. Which version of PHP introduced class type hints?

a) PHP 4

b) PHP 4.3

c) PHP 5

d) PHP 5.3

Answer: c

312. Inheritance is the means by which one or more classes can be derived from a/an ___________
class.

a) base

b) abstract

c) null

d) predefined

Answer: a

313. What will be the output of the following PHP code?

<?php

class MyClass

}
class NotMyClass

$a = new MyClass;

var_dump($a instanceof MyClass);

var_dump($a instanceof NotMyClass);

?>

a)

bool(true)

bool(true)

b)

bool(false)

bool(false)

c)

bool(true)

bool(false)

d)

bool(false)

bool(true)

Answer: c

314. What will be the output of the following PHP code?

<?php
class ParentClass

class MyClass extends ParentClass

$a = new MyClass;

var_dump($a instanceof MyClass);

var_dump($a instanceof ParentClass);

?>

a)

bool(false)

bool(false)

b)

bool(true)

bool(true)

c)

bool(false)

bool(true)

d)

bool(true)
bool(false)

Answer: b

315. What will be the output of the following PHP code?

<?php

class MyClass

$a = new MyClass;

var_dump(!($a instanceof stdClass));

?>

a) bool(true)

b) bool(false)

c) error

d) none of the mentioned

Answer: a

316. What will be the output of the following PHP code?

<?php

interface MyInterface

class MyClass implements MyInterface

$a = new MyClass;
var_dump($a instanceof MyClass);

var_dump($a instanceof MyInterface);

?>

a)

bool(false)

bool(false)

b)

bool(true)

bool(true)

c)

bool(false)

bool(true)

d)

bool(true)

bool(false)

Answer: b

317. What should be used to refer to a method in the context of a class rather than an object you use?

a) ->

b) __

c) $

d) ::

Answer: d

318. Prior to which version of PHP did constructors took the name of the enclosing class.

a) PHP 4
b) PHP 5

c) PHP 5.3

d) PHP 5.4

Answer: b

319. Which method or property can only be accessed from within the enclosing class? Even subclasses
have no access.

a) public

b) friendly

c) private

d) protected

Answer: c

320. A mutator method is also called as ___________

a) Setter

b) Accessor

c) Getter

d) Destructor

Answer: a

321. When you are building administrative links you’ll need to accept two arguments, which of the
following are they?

a) URL of previous entry and URL of the entry you are working with

b) The current page and previous page

c) URL of previous entry and previous page

d) The current page and URL of the entry you are working with

Answer: d

322. Once your application can generate administrative links, you need to load those links into
_________

a) php.ini

b) index.ini

c) index.php
d) start.php

Answer: c

323. The URLs in the administrative links won’t mean anything to admin.php unless you modify
_________

a) .htaccess

b) .adminaccess

c) .htmlaccess

d) .urlaccess

Answer: a

324. The (|/) tells the server to match ___________

a) nothing

b) forward slash

c) backward slash

d) either nothing or a forward slash

Answer: d

325. ([\w-]+) will match ___________

a) one word characters

b) one or more word characters

c) one or more word characters and/or hyphens

d) one or more word characters and hyphens

Answer: c

326. You need to check whether ______ is set, to determine whether you’re editing an entry or creating
a new one.

a) $_GET*‘url’+

b) $_SET*‘url’+

c) $_GET*‘admin’+

d) $_SET*‘admin’+

Answer: a
327. To identify entries marked for deletion, you check whether $_GET*‘page’+ == ‘delete’ inside
__________

a) index.php

b) index.ini

c) admin.php

d) .htaccess

Answer: c

328. To declare the function to confirm the deletion you need to add the code to __________

a) inc.php

b) functions.inc.php

c) include.php

d) functions.include.php

Answer: b

329. Your confirmation form submits your choice, via the _______ method, to ________

a) GET index.php

b) GET admin.php

c) POST index.php

d) POST admin.php

Answer: d

330. When a user confirms that he wishes to delete an entry, that entry’s URL is passed to a function
which removes the entry from the __________

a) index.php

b) function.inc.php

c) database

d) admin.php

Answer: c

331. Before you can start processing images with PHP, you must first add the ability to upload images to
your administrative form on ________

a) .htaccess
b) function.inc.php

c) index.php

d) admin.php

Answer: d

332. When you’re uploading files you need to set the enctype of the form to __________

a) text

b) text/file

c) multipart/form-data

d) multimedia/form-data

Answer: c

333. To check whether a file was uploaded, you look in the _______ superglobal array.

a) $_FILES

b) $_DOCS

c) $_DOCUMENTS

d) $_FOLDERS

Answer: a

334. To make the ImageHandler class portable you should create a separate file for it called __________

a) imagehandler.inc.php

b) images.inc.php

c) handler.inc.php

d) imghandler.inc.php

Answer: b

335. DocBlocks are indicated by opening a comment using _________

a) /*

b) //*

c) /**

d) /*/

Answer: c
336. To process the file, you need to break the array from $_FILES into individual values. You can do this
using the ________ function.

a) divide()

b) list()

c) break()

d) indi()

Answer: b

337. Before you try to process the file, you need to make sure that your $err value is equivalent to
_________

a) UPLOAD_ERR_OK

b) UPLOAD_NO_ERR

c) UPLOAD_ERR_NO_OK

d) UPLOAD_ERR

Answer: a

338. You use the $_SERVER superglobal and your _______ property to create your path to check.

a) $load_dir

b) $load

c) $save

d) $save_dir

Answer: d

339. Which function do you have to use to check whether the $path you’ve stored exists?

a) path_dir()

b) path()

c) is_dir()

d) path_dir()

Answer: c

340. Which one of the following is true about the following line – $obj = new ImageHandler(‘/images/’,
array(400, 300));?

a) This snippet sets the maximum dimensions allowed to 400 pixels wide by 300 pixels high
b) This snippet sets the minimum dimensions allowed to 300 pixels wide by 400 pixels high

c) This snippet sets the minimum dimensions allowed to 400 pixels wide by 300 pixels high

d) This snippet sets the maximum dimensions allowed to 300 pixels wide by 400 pixels high

Answer: a

341. Which version of PHP introduced the static keyword?

a) PHP 4

b) PHP 5

c) PHP 5.2

d) PHP 5.3

Answer: b

342. Which keyword is used to access a static method or property from within the same class(rather
than from child)?

a) static

b) strat

c) self

d) set

Answer: c

343. In which of the following circumstance should you use a static reference to a non static method?

a) Making a method call using parent

b) Making a method call using child

c) Making an object call using parent

d) Making an object call using child

Answer: a

344. Which one of the following variable cannot be used inside a static method?

a) $this

b) $get

c) $set

d) $date
Answer: a

345. What does PDO stand for?

a) PHP Data Orientation

b) PHP Database Object

c) PHP Database Orientation

d) PHP Data Object

Answer: d

346. Which version of PHP allows you to define constant properties within a class?

a) PHP 4

b) PHP 4.1

c) PHP 4.3

d) PHP 5

Answer: d

347. Which keyword is used to declare a constant property?

a) const

b) con

c) constant

d) _constant

Answer: a

348. Which one of the following is a constant variable?

a) const $name

b) const $NAME

c) constant NAME

d) const NAME

Answer: d

349. What will happen if you try to set a value to a constant once it has been declared?

a) The value of the variable will change

b) The value of the variable will not change


c) Parse Error

d) Nothing

Answer: c

350. How many of the following can be contained in constants?

i) boolean

ii) integer

iii) float

iv) string

a) 1

b) 2

c) 3

d) 4

Answer: d

351. Which one of the following class can not be instantiated?

a) inherited class

b) abstract class

c) constant class

d) every class

Answer: b

352. Which one of the following keywords are used to define an abstract class?

a) extends

b) implements

c) abstract

d) new

Answer: c

353. Which one of the following is the correct abstract method?

a) public function write()

b) abstract function write()


c) abstract public write();

d) abstract public function write();

Answer: d

354. At least how many abstract methods must an abstract class contain?

a) None

b) One

c) Two

d) Five

Answer: b

355. Which one of the following keyword is used to implement an interface?

a) interface

b) get

c) inherit

d) implements

Answer: d

356. Which version of PHP introduced the concept called late static binding?

a) PHP 4

b) PHP 5

c) PHP 5.1

d) PHP 5.3

Answer: d

357. Which one of the following methods in the exception class, is used to get a nested exception
object?

a) getPrevious()

b) getCode()

c) getFile()

d) getLine()

Answer: a
358. Which one of the following keyword is used in conjunction with an Exception object?

a) throws

b) exception

c) throw

d) final

Answer: c

359. Which keyword is used to put a stop on inheritance?

a) stop

b) end

c) break

d) final

Answer: d

350. PHP provides built-in interceptor methods, which can intercept messages sent to undefined
methods and properties. This is also known as _________

a) overloading

b) overriding

c) overbending

d) overbinding

Answer: a

351. Which one of the following method is invoked when a value is assigned to an undefined property?

a) __get()

b) __set()

c) __isset()

d) __call()

Answer: b

352. Which one of the following method is invoked when an undefined method is called by client code?

a) __get()

b) __isset()
c) __unset()

d) __call()

Answer: d

353. Which method introduced in PHP 5, is invoked just before an object is a garbage collected?

a) __collect()

b) __garbage()

c) __destruct()

d) __destructor()

Answer: c

354. Which one of the following PHP statements is true?

class CopyMe {}

$first = new CopyMe();

$second = $first;

a) In PHP 4: $second and $first are 2 distinct objects

b) In PHP 5: $second and $first are 2 distinct objects

c) In PHP 4: $second and $first refer to one object

d) None of the mentioned

Answer: a

355. Which keyword must be added before $first variable on the third line of the above question to
make $second and $first as distinct objects in PHP 5?

a) copy

b) clone

c) cut

d) Can’t add any word to make them distinct

Answer: b

356. What will be the output of the following PHP code? (Before the version PHP 5.2)
class StringThing {}

$st = new StringThing();

print $st;

a) Object Not Found

b) Object id #1

c) PHP Catchable fatal error

d) Cannot initialize object

Answer: b

357. What will be the output of the following PHP code?

class Person

function getName() { return "Bob"; }

function getAge() { return 44; }

function __toString() {

$desc = $this->getName();

$desc .= " (age ".$this->getAge().")";

return $desc;

$person = new Person();

print $person;

a) Object Not Found

b) PHP Catchable fatal error

c) BOB (age 44)

d) BOB

Answer: c

358. __clone() is run on the ___ object.


a) original

b) pseudo

c) external

d) copied

Answer: d

359. Which method is invoked when an undefined property is accessed?

a) __get()

b) __isset()

c) __unset()

d) __undefined()

Answer: a

360. What will be the output of the following PHP code?

class Checkout

final function totalize()

// calculate bill

class IllegalCheckout extends Checkout

final function totalize()

// change bill calculation

}
a) PHP Fatal error: Class IllegalCheckout may not inherit from final class

b) Value of the bill calculated

c) PHP Fatal error: Cannot find object

d) PHP Fatal error: Cannot override final method

Answer: d

361. A package is a set of related _________

a) Objects

b) Classes

c) Programs

d) Functions

Answer: b

362. Till which version of PHP, developers were forced to name their files in a global context?

a) PHP 4

b) PHP 5

c) PHP 5.2

d) PHP 5.3

Answer: d

363. Which of the following can you place inside a namespace?

i) classes

ii) functions

iii) variables

a) i)

b) ii)

c) iii)

d) i), ii) & iii)

Answer: d

364. Which one of the following is the correct way of declaring a namespace?

a) namespace my;
b) namespace my();

c) my namespace;

d) namespace(my);

Answer: a

365. Which symbol is used to declare nested namespaces?

a) /

b) \

c) .

d) |

Answer: b

366. Output:

namespace main;

com\getinstance\util\Debug::helloWorld()

PHP Fatal error: Class 'main\com\getinstance\util\Debug' not found in ...

Using which one of the following PHP lines will the error be removed?

a) \\com\getinstance\util\Debug::helloWorld();

b) getinstance\util\Debug::helloWorld();

c) main.com\getinstance\util\Debug::helloWorld();

d) \com\getinstance\util\Debug::helloWorld();

Answer: d

367. Which keyword can be used to fix the following PHP error?

namespace main;

com\getinstance\util\Debug::helloWorld()

PHP Fatal error: Class 'main\com\getinstance\util\Debug' not found in ...

a) fix

b) join
c) use

d) namespace

Answer: c

368. If I already had a Debug class in the main namespace. What will be the output of the following PHP
code?

namespace main;

use com\getinstance\util\Debug;

class Debug {

static function helloWorld() {

print "hello from main\Debug";

Debug::helloWorld();

a) error

b) hello from main

c) hello from main\Debug

d) debug

Answer: a

369. Which one of the following statements is true for include_once() and require_once()?

a) Both are exactly the same

b) include_once is used for files where as require_once() is not

c) Both Handle the errors in the same way

d) Both do not handle the errors in the same way

Answer: d

370. Which one of the following statements is true for require() and require_once()?
a) They are functions

b) They are statements

c) They’ll not work if the () is not present

d) They can not be used to require files

Answer: b

371. Which function was introduced to help automate the inclusion of class files?

a) __load()

b) __preload()

c) __autoload()

d) __inload()

Answer: c

372. How many times can you define _________ autoload in a process?

a) once

b) twice

c) thrice

d) as many times as needed

Answer: a

373. Which one of the following functions will you use to check that the class exists before you work
with it?

a) class_exist()

b) class_exists()

c) exist()

d) exists_class()

Answer: b

374. Which one of the following will you use to check the class of an object?

a) class()

b) _class()

c) class_check()
d) get_class()

Answer: d

375. PHP 4 did not support instanceof. Instead, which function did it provide?

a) is()

b) get_class()

c) is_a()

d) is_the()

Answer: c

376. You use the get_class_methods() function to return the names of all the methods in the class.
Which function will you use to print it on the screen?

a) printf()

b) print_ar

c) print_r

d) echo

Answer: c

377. If you call a method and it doesn’t exist it’ll cause a problem. To check the method which function
will you use?

a) _method()

b) methodexists()

c) is_callable()

d) is_method()

Answer: c

378. What will be the output if a protected method is given as the argument to the function
method_exist()?

a) Method does not exist

b) False

c) Error

d) True

Answer: d
379. Which one of the following function should I use to find the parent class of a class?

a) get_parent_class()

b) parent_class()

c) class_parent()

d) get_class_parent()

View Answer

Answer: a

380. Which class accepts a class name or an object reference and returns an array of interface name?

a) class_implements()

b) is_subclass()

c) is_subclass_of()

d) class_interface()

Answer: a

381. Object-oriented code tries to minimize dependencies by moving responsibility for handling tasks
away from ___ and toward the objects in the system.

a) server code

b) client code

c) machine code

d) procedural code

Answer: b

382. Placing a static method for generating ________ objects in the ____________ class is convenient.

a) child parent

b) parent child

c) final static

d) static final

Answer: a

383. The extent to which proximate procedures are related to one another is known as ________
a) Coupling

b) Balancing

c) Cohesion

d) Co-relation

Answer: c

384. ______ occurs when discrete parts of a system’s code are tightly bound up with one another so
that a change in one part necessitates changes in the others.

a) Loose Coupling

b) Tight Coupling

c) Co-relation

d) Balancing

Answer: b

385. ________ code makes change easier because the impact of altering an implementation will be
localized to the component being altered.

a) Orthogonal

b) Cohesion

c) Coupling

d) Balancing

Answer: a

386. Polymorphism is also known as______

a) switch

b) overact

c) encapsulation

d) class switching

Answer: d

387. Which one of the following is known as the key to object-oriented programming?

a) Polymorphism

b) Encapsulation
c) Data Abstraction

d) Orthogonality

Answer: b

388. Which one among the following means tight coupling?

a) Code Duplication

b) Inheritance

c) Encapsulation

d) Polymorphism

Answer: a

389. UML stands for?

a) unified mailing language

b) unified modeling logo

c) undefined modeling language

d) unified modeling language

Answer: d

390. In a class diagram the class is divided into three sections, what is displayed in the first section?

a) Class Attributes

b) Class Declaration

c) Class Name

d) Class Functions

Answer: c

391. ________ are used in class diagrams to describe the way in which specific elements should be used.

a) Attributes

b) Constraints

c) Constants

d) Class Names

Answer: b

392. Which one of the following is displayed below the class name in the class diagrams?
a) Functions

b) Methods

c) Attributes

d) Constraints

Answer: c

393. + is the visibility code for?

a) Public

b) Private

c) Protected

d) Friendly

Answer: a

394. Which relationship is illustrated by a line that begins with an unfilled diamond?

a) Composition

b) Abstraction

c) Aggregation

d) Inheritance

Answer: c

395. If the diamond is filled it depicts which relationship?

a) Strong Aggregation

b) Composition

c) Abstraction

d) Inheritance

Answer: b

396. Which one of the following statements is true about sequence diagrams?

a) A sequence diagram is class based

b) A sequence diagram presents the participants of a system from right to left

c) The vertical broken lines represent the lifetime of the class in the system

d) A sequence diagram is object based


Answer: d

397. A bidirectional relationship in class diagrams is described by________

a) double-headed arrow

b) visibility symbols

c) single-headed arrow

d) double diamond

Answer: a

398. # is the visibility code for?

a) Private

b) Friendly

c) Protected

d) Static

Answer: c

399. Which one of the following is displayed in the third section of the class diagram?

a) Operations

b) Inheritance

c) Abstraction

d) Coupling

Answer: a

400. Inheritance in class diagrams is depicted by________

a) single-headed empty arrow

b) single-headed filled arrow

c) double-headed empty arrow

d) double-headed filled arrow

Answer: a

401. What will be the output of the following PHP code?

<?php
"Hello World"

?>

a) Error

b) Hello World

c) Nothing

d) Missing semicolon error

Answer: c

402. What will be the output of the following PHP code?

<?php

print_r "Hello world"

?>

a) Error

b) Hello World

c) Nothing

d) Missing semicolon error

Answer: a

403. What will be the output of the following PHP code?

<?php

echo 'Hello World';

<html>

Hello world

</html>

?>

a) Hello world

b) Hello World Hello World

c)
Hello world

Hello World

d) Syntax Error

Answer: d

Explanation: Parse error: syntax error, unexpected ‘<‘ on line 2. You can not use the html tag inside php
tags.

404. What will be the output of the following PHP code?

<?php

Echo "Hello World1";

echo " Hello world2";

ECHO " Hello world3";

?>

a) Hello world1 Hello world2 Hello World3

b)

Hello world1

Hello world2

Hello World3

c) Error

d) Hello world1 Hello world3

Answer: a

405. What will be the output of the following PHP code?

<?php

$color = "red";

echo "$color";
echo "$COLOR";

echo "$Color";

?>

a) redredred

b) redred

c) red

d) Error

Answer: c

406. What will be the output of the following PHP code?

<?php

# echo "Hello world";

echo "# Hello world";

?>

a) # Hello world

b) Hello world# Hello world

c) Hello world

d) Error

Answer: a

407. What will be the output of the following PHP code?

<?php

echo "<i>Hello World</i>"

?>

a) Hello world

b) Hello world in italics

c) Nothing

d) Error
Answer: b

408. What will be the output of the following PHP code?

<?php

echo "echo "Hello World"";

?>

a) Hello world

b) echo “Hello world”

c) echo Hello world

d) Error

Answer: d

409. What will be the output of the following PHP code?

<?php

<?php

echo "Hello world";

?>

?>

a) HELLO WORLD

b) Hello world

c) Nothing

d) Error

Answer: d

500. What will be the output of the following PHP code?

<?php

$color = red;

echo "\$color";
?>

a) red

b) $color

c) \red

d) Error

Answer: b

501. What will be the output of the following PHP code?

<?php

/*

echo "Hello world";

*/

?>

a) Hello world

b) Nothing

c) Error

d)

/*

Hello world

*/

Answer: b

502. What will be the output of the following PHP code?

<?php

$color = red;

echo "$color" . red ;

?>
a) red red

b) red

c) error

d) nothing

Answer: c

503. What will be the output of the following PHP code?

<?php

$color1 = red;

$color2 = green;

echo "$color1"."$color2";

?>

a) red green

b) red

c) green

d) error

Answer: d

504. What will be the output of the following PHP code?

<?php

$color = "red";

$color = "green";

echo "$color";

?>

a) red

b) green

c) red green

d) error
Answer: b

505. What will be the output of the following PHP code?

<?php

$color1 = "red";

$color2 = "green";

echo "$color1" . "$color2";

?>

a) red

b) green

c) red green

d) redgreen

Answer: d

506. What will be the output of the following PHP code?

<?php

$color1 = "red";

$color2 = "green";

echo "$color1" + "$color2";

?>

a) redgreen

b) red green

c) 0

d) error

Answer: c

507. What will be the output of the following PHP code?

<?php
$color1 = "red";

$color2 = "red";

echo "$color1" + "$color2";

?>

a) redgreen

b) red green

c) 0

d) 1

Answer: c

508. What will be the output of the following PHP code?

<?php

$color1 = "red";

$color2 = "1";

echo "$color1" + "$color2";

?>

a) red1

b) red 1

c) 0

d) 1

Answer: d

509. What will be the output of the following PHP code?

<?php

$color1 = "1";

$color2 = "1";

echo "$color1" + "$color2";

?>
a) 11

b) 2

c) 0

d) 1

Answer: b

510. What will be the output of the following PHP code?

<?php

$color1 = "red";

$color2 = "1";

$color3 = "grey"

echo "$color1" + "$color2" . "$color3";

?>

a) 1grey

b) grey

c) 0

d) red1grey

Answer: a

511. What will be the output of the following PHP code?

<?php

$x = 5;

$y = 10;

$z = "$x + $y";

echo "$z";

?>

a) 15

b) 10 + 5
c) $z

d) $x + $y

Answer: b

512. What will be the output of the following PHP code?

<?php

$x = 4;

$y = 3;

$z = 1;

echo "$x = $x + $y + $z";

?>

a) 4 = 4 + 3 + 1

b) 8

c) 8 = 4 + 3 +1

d) Error

Answer: a

513. What will be the output of the following PHP code?

<?php

$x = 4;

$y = 3

$z = 1;

$z = $z + $x + $y;

echo "$z";

?>

a) $z

b) 15

c) 8
d) 1

Answer: c

514. What will be the output of the following PHP code?

<?php

$x = 3.3;

$y = 2;

echo $x % $y;

?>

a) 0

b) 1

c) 2

d) Error

Answer: b

515. What will be the output of the following PHP code?

<?php

$x = 10;

$y = 4;

$z = 3;

echo $x % $y % $z;

?>

a) 0

b) 1

c) 2

d) Error

Answer: c

516. What will be the output of the following PHP code?


<?php

$x = 10;

$y = 4;

$z = 3;

echo ($x % ($y) + $z);

?>

a) 5

b) 3

c) 0

d) 1

Answer: a

517. What will be the output of the following PHP code?

<?php

$x = 30;

$y = 20;

$z = 10;

echo $x + $y - $z / ($z - $y);

?>

a) 41

b) -4

c) -5

d) 51

Answer: d

518. What will be the output of the following PHP code?

<?php
$x = -1;

$y = 1;

$z = $x * $y + $z;

echo $z;

?>

a) Undefined variable z

b) -1

c)

Undefined variable z

-1

d) None of the mentioned

Answer: c

519. What will be the output of the following PHP code?

<?php

$x = 4;

$y = -3;

$z = 11;

echo 4 + $y * $z / $x;

?>

a) 4.25

b) 3.25

c) -3.25

d) -4.25

Answer: d

520. What will be the output of the following PHP code?


<?php

$x = 3.5;

$y = 2;

$z = 2;

echo $x / $y / $z;

?>

a) 1.75

b) 0.875

c) 3.5

d) Error

Answer: b

521. What will be the output of the following PHP code?

<?php

one = 1;

two = 2;

three = 3;

four = 4;

echo "one / two + three / four";

?>

a) 0.75

b) 0.05

c) 1.25

d) Error

Answer: d

522. What will be the output of the following PHP code?

<?php
$on$e = 1;

$tw$o = 2;

$thre$e = 3;

$fou$r = 4;

echo "$on$e / $tw$o + $thre$e / $fou$r";

?>

a) 0.75

b) 0.05

c) 1.25

d) Error

Answer: d

523. What will be the output of the following PHP code?

<?php

$on_e = 1;

$tw_o = 2;

$thre_e = 3;

$fou_r = 4;

echo $on_e / $tw_o + $thre_e / $fou_r;

?>

a) 0.75

b) 0.05

c) 1.25

d) Error

Answer: c

524. What will be the output of the following PHP code?

<?php
$On_e = 1;

$tw_o = 2;

$thre_e = 3;

$fou_r = 4;

echo $on_e / $tw_o + $thre_e / $fou_r;

?>

a) 0.75

b) 0.05

c) 1.25

d) Error

Answer: a

525. What will be the output of the following PHP code?

<?php

echo $red;

?>

a) 0

b) Nothing

c) True

d) Error

Answer: b

526. What will be the output of the following PHP code?

<?php

$four4 = 4;

$three3 = 3;

$two2 = 2;

echo $four4 + $three3 / $two2 - 1;


?>

a) 4.5

b) 7

c) 3.5

d) Error

Answer: a

527. What will be the output of the following PHP code?

<?php

$4four = 4;

$3three = 3;

$2two = 2;

echo $4four + $3three / $2two - 1;

?>

a) 4.5

b) 7

c) 3.5

d) Error

Answer: d

528. What will be the output of the following PHP code?

<?php

int $one = 1;

echo "$one";

?>

a) 0

b) 1

c) $one
d) Error

Answer: d

529. What will be the output of the following PHP code?

<?php

var $one = 1;

var $two = 2;

echo $one / $two * $one / $two * $two;

?>

a) 1

b) 0

c) 0.5

d) Error

Answer: d

530. What will be the output of the following PHP code?

<?php

$hello = "Hello World";

$bye = "Bye";

echo $hello;"$bye";

?>

a) Hello World

b) Bye

c) Hello worldBye

d) Error

Answer: a

531. What will be the output of the following PHP code?


<?php

$x;

echo "$x";

?>

a) 0

b) 1

c) Nothing

d) Error

Answer: c

532. What will be the output of the following PHP code?

<?php

$x = 5;

$x = 10;

echo "$x";

echo "$x";

?>

a) 1010

b) 105

c) 510

d) error

Answer: a

533. What will be the output of the following PHP code?

<?php

$x = 5;
{

echo "$x";

?>

a) 0

b) 5

c) Nothing

d) Error

Answer: b

534. What will be the output of the following PHP code?

<?php

$x = 5;

function fun()

echo "$x";

fun();

?>

a) 0

b) 5

c) Nothing

d) Error

Answer: c

535. What will be the output of the following PHP code?

<?php

$x = 5;
function fun()

$x = 10;

echo "$x";

fun();

echo "$x";

?>

a) 0

b) 105

c) 510

d) Error

Answer: b

536. What will be the output of the following PHP code?

<?php

$x = 4;

$y = 3;

function fun($x = 3, $y = 4)

$z = $x+$y/$y+$x;

echo "$z";

echo $x;

echo $y;

echo $z;

fun($x, $y);

?>
a) 43

b) 943

c) 349

d) 439

537. What will be the output of the following PHP code?

<?php

$x = 4;

$y = 3;

function fun($x, $y)

$z = $x + $y / $y + $x;

echo "$z";

echo $x;

echo $y;

echo $z;

fun(3, 4);

?>

a) 437

b) 439

c) 349

d) 347

Answer: a

538. What will be the output of the following PHP code?

<?php

function fun($x,$y)
{

$x = 4;

$y = 3;

$z = $x + $y / $y + $x;

echo "$z";

fun(3, 4);

?>

a) 7

b) 9

c) 0

d) Error

Answer: b

539. What will be the output of the following PHP code?

<?php

$x = 3, 4, 5, 6;

echo "$x";

?>

a) 3

b) 4

c) 6

d) Error

Answer: d

540. What will be the output of the following PHP code?

<?php

$a = 10;
$b = 4;

$c = fun(10,4);

function fun($a,$b)

$b = 3;

return $a - $b + $b - $a;

echo $a;

echo $b;

echo $c;

?>

a) 104

b) 410

c) 1400

d) 4100

Answer: c

541. What will be the output of the following PHP code?

<?php

$a = "$winner";

$b = "/$looser";

echo $a,$b;

?>

a) $winner/$looser

b) /$looser

c) /

d) $looser

Answer: c
542. What will be the output of the following PHP code?

<?php

$a = "$winner";

$b = "\$looser";

echo $a, $b;

?>

a) $winner\$looser

b) \$looser

c) \

d) $looser

Answer: d

543. What will be the output of the following PHP code?

<?php

$a = "$winner";

$b = "\\$looser";

echo $a, $b;

?>

a) $winner\\$looser

b) \\$looser

c) \

d) $looser

Answer: c

544. What will be the output of the following PHP code?

<?php

$x = 5;
$y = 10;

function fun()

$GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];

fun();

echo $y;

?>

a) 5

b) 10

c) 15

d) Error

Answer: c

545. What will be the output of the following PHP code?

<?php

$x = 5;

$y = 10;

function fun()

$y = $GLOBALS['x'] + $GLOBALS['y'];

fun();

echo $y;

?>

a) 5

b) 10

c) 15
d) Error

Answer: b

546. What will be the output of the following PHP code?

<?php

function fun()

$x = 0;

echo $x;

$x++;

fun();

fun();

fun();

?>

a) 012

b) 123

c) 000

d) 111

Answer: c

547. What will be the output of the following PHP code?

<?php

function fun()

static $x = 0;

echo $x;

$x++;
}

fun();

fun();

fun();

?>

a) 012

b) 123

c) 111

d) Error

Answer: a

548. What will be the output of the following PHP code?

<?php

static $x = 0;

function fun()

echo $x;

$x++;

fun();

fun();

fun();

?>

a) 012

b) 123

c) Nothing

d) Error

Answer: c
549. What will be the output of the following PHP code?

<?php

$x=0;

function fun()

echo $GLOBALS['x'];

$GLOBALS['x']++;

fun();

fun();

fun();

?>

a) 000

b) 012

c) 123

d) Error

Answer: b

550. What will be the output of the following PHP code?

<?php

$x = 0;

function fun()

echo $GLOBALS['x'];

$x++;

fun();

fun();
fun();

?>

a) 000

b) 012

c) Nothing

d) Error

Answer: a

551. What will be the output of the following PHP code?

<?php

echo "Hello world </br> I am learning PHP";

?>

a) Hello world

b) Hello world I am learning PHP

c)

Hello world

I am learning PHP

d) Error

Answer: c

552. What will be the output of the following PHP code?

<?php

echo "Hello world <strong>I am learning PHP</strong>"

?>

a) Hello world

b) Hello world I am learning PHP

c)

Hello world
I am learning PHP

d) Error

Answer: b

553. What will be the output of the following PHP code?

<?php

echo "This", "was", "a", "bad", "idea";

?>

a) This, was, a, bad, idea

b) This was a bad idea

c) Thiswasabadidea

d) Error

Answer: c

554. What will be the output of the following PHP code?

<?php

echo "This"."was"."a"."bad"."idea";

?>

a) This, was, a, bad, idea

b) This was a bad idea

c) Thiswasabadidea

d) Error

Answer: c

555. What will be the output of the following PHP code?

<?php

echo "This","was"|"a","bad"."idea";

?>

a) Thiswasabadidea

b) Thiswasbadidea
c) Thiswas a badidea

d) Thiswas abadidea

Answer: b

556. What will be the output of the following PHP code?

<?php

$one = "Hello";

$two = "World";

echo $one, $two;

?>

a) Hello World

b) Hello

c) World

d) HelloWorld

Answer: d

557. What will be the output of the following PHP code?

<?php

$one = "Hello";

$two = "World";

echo "$one$two";

?>

a) HelloWorld

b) $one$two

c) Hello

d) Error

Answer: a

558. What will be the output of the following PHP code?

<?php

$one = "Hello";
$two = "World";

echo "$one"+"$two";

?>

a) HelloWorld

b) Hello+World

c) 0

d) Error

Answer: c

559. What will be the output of the following PHP code?

<?php

echo "This is <i>India</i>";

?>

a) This is India

b) This is India

c) This is

d) Error

Answer: b

560. What will be the output of the following PHP code?

<?php

$cars = array("Volvo", "BMW", "Toyota");

echo "My car is a {$cars[0]}";

?>

a) My car is a Volvo

b) My car is a BMW

c) My car is a Toyota

d) Error
Answer: a

561. What will be the output of the following PHP code?

<?php

print "echo hello world";

?>

a) echo hello world

b) hello world

c) nothing

d) error

Answer: a

562. What will be the output of the following PHP code?

<?php

$one = 1;

print($one);

print $one;

?>

a) 01

b) 11

c) 10

d) Error

Answer: b

563. What will be the output of the following PHP code?

<?php

$cars = array("Volvo", "BMW", "Toyota");

print $cars[2];

?>

a) Volvo

b) BMW
c) Toyota

d) Error

Answer: c

564. What will be the output of the following PHP code?

<?php

$one = "one";

$two = "two";

print($one$two);

?>

a) onetwo

b) one

c) nothing

d) error

Answer: d

565. What will be the output of the following PHP code?

<?php

$one = "one";

$two = "two";

print($one,$two);

?>

a) onetwo

b) one, two

c) one

d) error

Answer: d

566. What will be the output of the following PHP code?

<?php

$one = "one";
$two = "two";

print("$one$two");

?>

a) onetwo

b) $one$two

c) one

d) error

Answer: a

567. What will be the output of the following PHP code?

<?php

$one = "one";

$two = "two";

print($one==$two);

?>

a) true

b) false

c) nothing

d) error

Answer: c

568. What will be the output of the following PHP code?

<?php

$one = "one";

$two = "one";

print($one == $two);

?>

a) true

b) false

c) 1
d) error

Answer: c

569. What will be the output of the following PHP code?

<?php

print "Hello world!<br>";

print "I'm about to learn PHP!";

?>

a) Hello world!

I’m about to learn PHP!

b) Hello world! I’m about to learn PHP!

c)

Hello world!

I'm about to learn PHP!

d) Error

Answer: c

570. What will be the output of the following PHP code?

<?php

print("this"."was"."a"."bad"."idea");

?>

a) thiswasabadidea

b) this was a bad idea

c) nothing

d) error

Answer: a

571. What will be the output of the following PHP code?

<?php

define("GREETING", "PHP is a scripting language", true);


echo GREETING;

echo "<br>"

echo GREETING;

?>

a) PHP is a scripting language

b)

GREETING

GREEtING

c) GREETING

d)

PHP is a scripting language

PHP is a scripting language

Answer: d

572. What will be the output of the following PHP code?

<?php

define("GREETING", "PHP is a scripting language");

echo $GREETING;

?>

a) $GREETING

b) no output

c) PHP is a scripting language

d) GREETING

Answer: b

573. What will be the output of the following PHP code?

<?php

define('GREETING_TEST', 'PHP is a scripting language', true);


echo GREETING_TESt;

$changing_variable = 'test';

echo constant('GREETING_' . strtoupper($changing_variable));

?>

a)

PHP is a scripting language

PHP is a scripting language

b) GREETING_TESt

c) PHP is a scripting language

d)

PHP is a scripting language

GREETING_TEST

Answer: a

574. What will be the output of the following PHP code?

<?php

class Constants

define('MIN_VALUE', '0.0');

define('MAX_VALUE', '1.0');

public static function getMinValue()

return self::MIN_VALUE;

public static function getMaxValue()

return self::MAX_VALUE;
}

echo Constants::getMinValue();

echo Constants::getMaxValue();

?>

a) 0.01.0

b) 01

c) No output

d) ERROR

Answer: d

575. What will be the output of the following PHP code?

<?php

define("__LINE__", "PHP is a scripting language");

echo __LINE__;

?>

a) PHP is a scripting language

b) __LINE__

c) 2

d) ERROR

Answer: c

576. What will be the output of the following PHP code?

<?php

define('IF', 42);

echo "IF: ", IF;

?>

a) IF:42

b) No output

c) IF:
d) ERROR

Answer: d

577. What will be the output of the following PHP code?

<?php

define("NEW_GOOD_NAME_CONSTANT", "I have a value");

define("OLD_BAD_NAME_CONSTANT", NEW_GOOD_NAME_CONSTANT);

echo NEW_GOOD_NAME_CONSTANT;

echo OLD_BAD_NAME_CONSTANT;

?>

a) I have a value

b) I have a valueI have a value

c) ERROR

d) I have a valueNEW_GOO_NAME_CONSTANTS

Answer: b

578. What will be the output of the following PHP code?

<?php

define('GOOD_OCTAL', 0700);

define('BAD_OCTAL', 0600);

print GOOD_OCTAL;

print '<br>';

print BAD_OCTAL;

?>

a)

448

384

b)
0700

0800

c) ERROR

d) No output

Answer: a

579. What will be the output of the following PHP code?

<?php

define("VAR_NAME","test");

${VAR_NAME} = "value";

echo VAR_NAME;

echo ${VAR_NAME};

?>

a) test

b) testtest

c) testvalue

d) error, constant value cannot be changed

Answer: c

580. What will be the output of the following PHP code?

<?php

class myObject { }

define('myObject::CONSTANT', 'test');

echo myObject::CONSTANT;

?>

a) test

b) error

c) myObject::CONSTANT

d) no output
Answer: b

581. What will be the output of the following PHP code?

<?php

$a = 10;

echo ++$a;

echo $a++;

echo $a;

echo ++$a;

?>

a) 11111213

b) 11121213

c) 11111212

d) 11111112

Answer: a

582. What will be the output of the following PHP code?

<?php

$a = 12;

--$a;

echo $a++;

?>

a) 11

b) 12

c) 10

d) error

Answer: a

583. What will be the output of the following PHP code?

<?php

$x = "test";
$y = "this";

$z = "also";

$x .= $y .= $z ;

echo $x;

echo $y;

?>

a) testthisthisalso

b) testthis

c) testthisalsothisalso

d) error at line 4

Answer: c

584. What will be the output of the following PHP code?

<?php

$x = 1;

$y = 2;

if (++$x == $y++)

echo "true ", $y, $x;

?>

a) no output

b) true 23

c) true 22

d) true 33

Answer: b

585. What will be the output of the following PHP code?

<?php

$y = 2;
$w = 4;

$y *= $w /= $y;

echo $y, $w;

?>

a) 80.5

b) 44

c) 82

d) 42

Answer: d

586. What will be the output of the following PHP code?

<?php

$y = 2;

if ($y-- == ++$y)

echo $y;

?>

a) 2

b) 1

c) 3

d) no output

Answer: a

587. What will be the output of the following PHP code?

<?php

$y = 2;

if (**$y == 4)

echo $y;
}

?>

a) 4

b) 2

c) error at line2

d) no output

Answer: c

588. What will be the output of the following PHP code?

<?php

$y = 2;

if (--$y == 2 || $y xor --$y)

echo $y;

?>

a) 1

b) 0

c) 2

d) no output

Answer: b

589. What will be the output of the following PHP code?

<?php

$y = 2;

if (--$y <> ($y != $y++))

echo $y;

?>
a) 1

b) 0

c) 2

d) no output

Answer: b

590. What will be the output of the following PHP code?

<?php

echo $x-- != ++$x;

?>

a) 1

b) 0

c) error

d) no output

Answer: a

591. What will be the output of the following PHP code?

<?php

$auth = 1;

$status = 1;

if ($result = (($auth == 1) && ($status != 0)))

print "result is $result<br />";

?>

a) result is true

b) result is 1

c) error

d) no output

Answer: b
592. What will be the output of the following PHP code?

<?php

$i = 0;

while ($i = 10)

print "hi";

print "hello";

?>

a) hello

b) infinite loop

c) hihello

d) error

Answer: b

593. What will be the output of the following PHP code?

<?php

$i = "";

while ($i = 10)

print "hi";

print "hello";

?>

a) hello

b) infinite loop

c) hihello

d) error

Answer: b
594. What will be the output of the following PHP code?

<?php

$i = 5;

while (--$i > 0)

$i++;

print $i;

print "hello";

?>

a) 4hello4hello4hello4hello4hello…..infinite

b) 5hello5hello5hello5hello5hello…..infinite

c) no output

d) error

Answer: a

595. What will be the output of the following PHP code?

<?php

$i = 5;

while (--$i > 0 && ++$i)

print $i;

?>

a) 5

b) 555555555…infinitely

c) 54321

d) error

Answer: b
596. What will be the output of the following PHP code?

<?php

$i = 5;

while (--$i > 0 || ++$i)

print $i;

?>

a) 54321111111….infinitely

b) 555555555…infinitely

c) 54321

d) 5

Answer: a

597. What will be the output of the following PHP code?

<?php

$i = 0;

while(++$i || --$i)

print $i;

?>

a) 1234567891011121314….infinitely

b) 01234567891011121314…infinitely

c) 1

d) 0

Answer: a

598. What will be the output of the following PHP code?

<?php
$i = 0;

while (++$i && --$i)

print $i;

?>

a) 1234567891011121314….infinitely

b) 01234567891011121314…infinitely

c) no output

d) error

Answer: c

599. What will be the output of the following PHP code?

<?php

$i = 0;

while ((--$i > ++$i) - 1)

print $i;

?>

a) 00000000000000000000….infinitely

b) -1-1-1-1-1-1-1-1-1-1…infinitely

c) no output

d) error

Answer: a

600. What will be the output of the following PHP code?

<?php

$i = 2;

while (++$i)
{

while ($i --> 0)

print $i;

?>

a) 210

b) 10

c) no output

d) infinite loop

Answer: a

601. What will be the output of the following PHP code?

<?php

$i = 2;

while (++$i)

while (--$i > 0)

print $i;

?>

a) 210

b) 10

c) no output

d) infinite loop

Answer: d

602. What will be the output of the following PHP code?

<?php

echo 5 * 9 / 3 + 9;

?>
a) 24

b) 3.7

c) 3.85

d) 0

Answer: a

603. What will be the output of the following PHP code?

<?php

echo 5 * 9 / 3 + 9

?>

a) 24

b) 3.7

c) 3.85

d) 0

Answer: a

604. What will be the output of the following PHP code?

<?php

$i = 0;

$j = 0;

if ($i && ($j = $i + 10)) {

echo "true";

echo $j;

?>

a) 10

b) 0

c) true0

d) true10

Answer: b
605. What will be the output of the following PHP code?

<?php

$i = 10;

$j = 0;

if ($i || ($j = $i + 10)) {

echo "true";

echo $j;

?>

a) 20

b) true0

c) 0

d) true20

Answer: b

606. What will be the output of the following PHP code?

<?php

$i = 1;

if ($i++ && ($i == 1))

printf("Yes\n$i");

else

printf("No\n$i");

?>

a) No 2

b) Yes 1

c) Yes 2

d) No 1

Answer: a

607. What will be the output of the following PHP code?


<?php

$a = 1; $b = 3;

$d = $a++ + ++$b;

echo $d;

?>

a) 5

b) 4

c) 3

d) error

Answer: a

608. What will be the output of the following PHP code?

<?php

$a = 1; $b = 1; $d = 1;

print ++$a + ++$a+$a++; print $a++ + ++$b; print ++$d + $d++ + $a++;

?>

a) 869

b) 742

c) 368

d) error

Answer: a

609. What will be the output of the following PHP code?

<?php

$a = 10; $b = 10;

if ($a = 5)

$b--;

print $a;print $b--;

?>

a) 58
b) 59

c) 109

d) 108

Answer: b

610. What will be the output of the following PHP code?

<?php

$i = 0;

$x = $i++; $y = ++$i;

print $x; print $y;

?>

a) 02

b) 12

c) 01

d) 21

Answer: a

611. What will be the output of the following PHP code?

<?php

$a = 5; $b = -7; $c =0;

$d = ++$a && ++$b || ++$c;

print $d; print $a;

?>

a) 16

b) 06

c) 15

d) 05

Answer: a

612. What will be the output of the following PHP code?


<?php

$b = 1; $c = 4; $a = 5;

$d = $b + $c == $a;

print $d;

?>

a) 5

b) 0

c) 10

d) 1

Answer: d

613. What will be the output of the following PHP code?

<?php

echo 5 * 9 / 3 + 9;

?>

a) 24

b) 3.7

c) 3.85

d) 0

Answer: a

614. What will be the output of the following PHP code?

<?php

$var1 = 1 + ++5;

echo $var1;

?>

a) no output

b) error

c) 6

d) 7
Answer: b

615. What will be the output of the following PHP code?

<?php

$var1 = 0;

$var1 = ($var1 + 5)++;

echo $var1;

?>

a) 5

b) error

c) 6

d) 7

Answer: b

616. What will be the output of the following PHP code?

<?php

$var1 = 0;

$var1 = $var1++ + 5;

echo $var1;

?>

a) 5

b) error

c) 6

d) 7

Answer: a

617. What will be the output of the following PHP code?

<?php

$var1 = 0;

$var1 = ++$var1 + 5;
echo $var1;

?>

a) 5

b) error

c) 6

d) 7

Answer: c

618. What will be the output of the following PHP code?

<?php

$var1 = 0;

$var1 = $var1 + 5;

echo $var1++;

?>

a) 5

b) error

c) 6

d) 7

Answer: a

619. What will be the output of the following PHP code?

<?php

$var1 = 1;

echo $var1 = ++$var1 % 2 + ++$var1;

?>

a) 1

b) 0

c) 2
d) 3

Answer: d

620. What will be the output of the following PHP code?

<?php

$a = 5;$b = -7;$c =0;

$d = ++$a && ++$b || ++$c;

print $d;print $a;

?>

a) 16

b) 06

c) 15

d) 05

Answer: a

621. What will be the output of the following PHP code?

<?php

$var1 = 3;

print $var = ++$var;

?>

a) 1

b) 0

c) 2

d) 3

Answer: a

622. What will be the output of the following PHP code?

<?php
$var1 = 3;

print ++$var++;

?>

a) 3

b) 4

c) 5

d) error

Answer: d

623. What will be the output of the following PHP code?

<?php

$i = 0; $j = 1; $k = 2;

print !(($i + $k) < ($j - $k));

?>

a) 1

b) true

c) false

d) 0

Answer: a

624. What will be the output of the following PHP code?

<?php

$i = 0;$j = 1;$k = 2;

print !(( + + $i + $j) > ($j - $k));

?>

a) 1

b) no output

c) error
d) 0

Answer: b

625. What will be the output of the following PHP code?

<?php

$i = 0;$j = 1;$k = 2;

print (( + + $i + $j) >! ($j - $k));

?>

a) 1

b) no output

c) error

d) 0

Answer: a

626. What will be the output of the following PHP code?

<?php

$a = 0x6db7;

print $a<<6;

?>

a) 1797568

b) no output

c) error

d) 0x6dc0

Answer: a

627. What will be the output of the following PHP code?

<?php

$a = 'a' ;
print $a * 2;

?>

a) 192

b) 2

c) error

d) 0

Answer: d

628. What will be the output of the following PHP code?

<?php

$a = '4' ;

print + + $a;

?>

a) no output

b) error

c) 5

d) 0

Answer: c

629. What will be the output of the following PHP code?

<?php

$a = '12345';

print "qwe{$a}rty";

?>

a) qwe12345rty

b) qwe{$a}rty

c) error

d) no output
Answer: a

630. What will be the output of the following PHP code?

<?php

$a = '12345';

print "qwe".$a."rty";

?>

a) qwe12345rty

b) qwe$arty

c) error

d) no output

Answer: a

631. What will be the output of the following PHP code?

<?php

$a = '12345';

echo 'qwe{$a}rty';

?>

a) qwe12345rty

b) qwe{$a}rty

c) error

d) no output

Answer: b

632. What will be the output of the following PHP code?

<?php

$a = '12345';

echo "qwe$arty";
?>

a) qwe12345rty

b) qwe$arty

c) qwe

d) error

Answer: c

633. What will be the output of the following PHP code?

<?php

$x;

if ($x)

print "hi" ;

else

print "how are u";

?>

a) how are u

b) hi

c) error

d) no output

Answer: a

634. What will be the output of the following PHP code?

<?php

$x = 0;

if ($x++)

print "hi";

else

print "how are u";


?>

a) hi

b) no output

c) error

d) how are u

Answer: d

635. What will be the output of the following PHP code?

<?php

$x;

if ($x == 0)

print "hi" ;

else

print "how are u";

print "hello"

?>

a) how are uhello

b) hihello

c) hi

d) no output

Answer: b

636. What will be the output of the following PHP code?

<?php

$x = 0;

if ($x == 1)

if ($x >= 0)

print "true";

else
print "false";

?>

a) true

b) false

c) error

d) no output

Answer: d

637. What will be the output of the following PHP code?

<?php

$a = 1;

if ($a--)

print "True";

if ($a++)

print "False";

?>

a) true

b) false

c) error

d) no output

Answer: a

638. What will be the output of the following PHP code?

<?php

$a = 1;

if (echo $a)

print "True";

else

print "False";
?>

a) true

b) false

c) error

d) no output

Answer: c

639. What will be the output of the following PHP code?

<?php

$a = 1;

if (print $a)

print "True";

else

print "False";

?>

a) true

b) false

c) error

d) no output

Answer: a

640. What will be the output of the following PHP code?

<?php

$a = 10;

if (1)

print "all";

else

print "some"
else

print "none";

?>

a) all

b) some

c) error

d) none

Answer: c

641. What will be the output of the following PHP code?

<?php

$a = 10;

if (0)

print "all";

if

else

print "some"

?>

a) all

b) some

c) error

d) no output

Answer: c

642. What will be the output of the following PHP code?

<?php

$a = "";

if ($a)
print "all";

if

else

print "some";

?>

a) all

b) some

c) error

d) no output

Answer: b

643. What will be the output of the following PHP code?

<?php

$a = "a";

if ($a)

print "all";

else

print "some";

?>

a) all

b) some

c) error

d) no output

Answer: a

644. What will be the output of the following PHP code?

<?php

$x = 10;
$y = 20;

if ($x > $y + $y != 3)

print "hi" ;

else

print "how are u";

?>

a) how are u

b) hi

c) error

d) no output

Answer: b

645. What will be the output of the following PHP code?

<?php

$x = 10;

$y = 20;

if ($x > $y && 1||1)

print "hi" ;

else

print "how are u";

?>

a) how are u

b) hi

c) error

d) no output

Answer: b

644. What will be the output of the following PHP code?


<?php

$x = 10;

$y = 20;

if ($x > $y && 1||1)

print "hi" ;

else

print "how are u";

?>

a) how are u

b) hi

c) error

d) no output

Answer: b

645. What will be the output of the following PHP code?

<?php

if (-100)

print "hi" ;

else

print "how are u";

?>

a) how are u

b) hi

c) error

d) no output

Answer: b

646. What will be the output of the following PHP code?


<?php

if (0.1)

print "hi" ;

else

print "how are u";

?>

a) how are u

b) hi

c) error

d) no output

Answer: b

647. What will be the output of the following PHP code?

<?php

if (0.0)

print "hi" ;

else

print "how are u";

?>

a) how are u

b) hi

c) error

d) no output

Answer: a

648. What will be the output of the following PHP code?

<?php

if (print "0")
print "hi" ;

else

print "how are u";

?>

a) 0how are u

b) 0hi

c) hi

d) how are u

Answer: b

649. What will be the output of the following PHP code?

<?php

$x = 1;

if ($x == 2)

print "hi" ;

else if($x = 2)

print $x;

else

print "how are u";

?>

a) error

b) 2

c) hi

d) how are u

Answer: b

650. What will be the output of the following PHP code?

<?php
$x = 1;

if ($x = $x&0)

print $x ;

else

print "how are u";

?>

a) 0

b) 1

c) error

d) how are u

Answer: d

651. What will be the output of the following PHP code?

<?php

$x = 1;

if ($x = $x&0)

print $x ;

else

print "how are u";

?>

a) 0

b) 1

c) error

d) how are u

Answer: d

652. What will be the output of the following PHP code?

<?php
$x = 1;

if ($x = $x&0)

print $x;

else

break;

?>

a) 0

b) 1

c) error

d) no output

Answer: c

653. What will be the output of the following PHP code?

<?php

$a = 100;

if ($a > 10)

printf("M.S. Dhoni");

else if ($a > 20)

printf("M.E.K Hussey");

else if($a > 30)

printf("A.B. de villiers");

?>

a) M.S.Dhoni

b) M.E.K.Hussey

c)M.S.Dhoni

M.E.K.Hussey

A.B.de villiers

d) No output
Answer: a

654. What will be the output of the following PHP code?

<?php

$x = 10;

$y = 5;

$z = 3;

if ($x / $y / $z)

print "hi";

else

print "hello";

?>

a) hi

b) hello

c) error

d) no output

Answer: a

655. What will be the output of the following PHP code?

<?php

if (!print "hi")

if (print "hello")

print "hi";

?>

a) hi

b) hihellohi

c) hihi

d) no output
Answer: a

656. What will be the output of the following PHP code?

<?php

if (print "hi" - 1)

print "hello"

?>

a) hi

b) hihello

c) error

d) no output

Answer: c

657. What will be the output of the following PHP code?

<?php

$x = 1;

if ($x--)

print "hi"

$x--;

else

print "hello"

?>

a) hi

b) hello

c) error

d) no output

Answer: c

658. What will be the output of the following PHP code?


<?php

$a = 10;

$b = 11;

if ($a < ++$a || $b < ++$b)

print "hello";

else

print "hi";

?>

a) hi

b) hello

c) error

d) no output

Answer: a

659. What will be the output of the following PHP code?

<?php

$a = 2;

if ($a-- - --$a - $a)

print "hello";

else

print "hi";

?>

a) hi

b) hello

c) error

d) no output

Answer: b

659. What will be the output of the following PHP code?


<?php

$a = 2;

if ($a-- - --$a - $a)

print "hello";

else

print "hi";

?>

a) hi

b) hello

c) error

d) no output

Answer: b

660. What will be the output of the following PHP code?

<?php

$a = "hello";

if ($a.length)

print $a.length;

else

print "hi";

?>

a) hellolength

b) 5

c) hi

d) error

Answer: a

661. What will be the output of the following PHP code?


<?php

$a = "hello";

if (strlen($a))

print strlen($a);

else

print "hi";

?>

a) hellolength

b) 5

c) hi

d) error

Answer: b

662. What will be the output of the following PHP code?

<?php

$a = "1";

$b = "0";

if ((int)$a && $b)

print"hi";

else

print "hello";

?>

a) hello

b) no output

c) hi

d) error

Answer: a

663. What will be the output of the following PHP code?


<?php

$a = "1";

switch ($a)

case 1:

print "hi";

case 2:

print "hello";

default:

print "hi1";

?>

a) hihellohi1

b) hi

c) hihi1

d) hi1

Answer: a

664. What will be the output of the following PHP code?

<?php

$a = "2";

switch ($a)

case 1:

print "hi";

case 2:

print "hello";

break;
default:

print "hi1";

?>

a) hihellohi1

b) hello

c) hihi1

d) hi1

Answer: b

665. What will be the output of the following PHP code?

<?php

$a = "1";

switch($a)

case 1:

break;

print "hi";

case 2:

print "hello";

break;

default:

print "hi1";

?>

a) hihellohi1

b) no output

c) hihi1
d) hi1

Answer: b

666. What will be the output of the following PHP code?

<?php

$a = "1";

$a = 1;

$b = 1;

switch($a)

case $a * $b:

print "hi";

break;

case $a / $b:

print "hello";

break;

default:

print "hi1";

?>

a) hihellohi1

b) hi

c) hihello

d) hi1

Answer: b

667. What will be the output of the following PHP code?

<?php

$a = 97;
switch($a)

case "a":

print "hi";

break;

case 97:

print "hello";

break;

default:

print "hi1";

?>

a) hihellohi1

b) hi

c) hihello

d) hello

Answer: d

668. What will be the output of the following PHP code?

<?php

$b = 1;

switch($b)

case 1.0:

print "hi";

break;

case 1:

print "hello";
break;

default:

print "hi1";

?>

a) hihellohi1

b) hi

c) hihello

d) hello

Answer: a

669. What will be the output of the following PHP code?

<?php

const $b = 1;

switch($b)

case 1:

print "hi";

break;

case 1:

print "hello";

break;

default:

print "hi1";

?>

a) error

b) hi
c) hihello

d) hello

Answer: a

670. What will be the output of the following PHP code?

<?php

$b = 1;

switch(print $b)

case 2:

print "hello";

break;

case 1:

print "hi";

break;

default:

print "hi1";

?>

a) 1hello

b) 1hi

c) 1hi1

d) error

Answer: b

671. What will be the output of the following PHP code?

<?php

switch($b)

{
case 2:

print "hello";

break;

case 1:

print "hi";

break;

?>

a) hello

b) hi

c) no output

d) error

Answer: c

672. What will be the output of the following PHP code?

<?php

switch($b)

case 2:

print "hello";

break;

case b:

print "hi";

break;

?>

a) hello

b) hi

c) no output
d) error

Answer: c

673. What will be the output of the following PHP code?

<?php

while()

print "hi";

?>

a) infinite loop

b) hi

c) no output

d) error

Answer: d

674. What will be the output of the following PHP code?

<?php

do

print "hi";

while(0);

print "hello";

?>

a) infinite loop

b) hihello

c) hello

d) error

Answer: b
675. What will be the output of the following PHP code?

<?php

$i = 0

do

print "hi";

$i++;

while ($i != 3);

?>

a)

hi

hi

b) hi

c)

hi

hi

hi

hi

d) no output

Answer: c

676. What will be the output of the following PHP code?

<?php

$i = 0

while ($i != 3)
{

print "hi";

$i++;

?>

a)

hi

hi

b)

hi

hi

hi

c)

hi

hi

hi

hi

d) no output

Answer: b

677. What will be the output of the following PHP code?

<?php

$i = 0

while ($i < 3)

{
print "hi";

$i--;

print "hello"

?>

a)

hi

hi

hello

b)

hi

hi

hi

hello

c)

hi

hi

hi

hi

hello

d) infinite loop

Answer: d

678. What will be the output of the following PHP code?

<?php
$i = 0

while ($i < 3)

$i++;

print $i;

?>

a) 2

b) 3

c) 0

d) 1

Answer: b

679. What will be the output of the following PHP code?

<?php

$i = 0

do

$i++;

while ($i < 3);

print $i;

?>

a) 2

b) 3

c) 0

d) 1

Answer: b
680. What will be the output of the following PHP code?

<?php

$i = 0

while ($i++)

print $i;

print $i;

?>

a) 0

b) infinite loop

c) 01

d) 1

Answer: d

681. What will be the output of the following PHP code?

<?php

$i = "";

while($i)

print "hi";

print "hello";

?>

a) hello

b) infinite loop

c) hihello

d) error
Answer: a

682. What will be the output of the following PHP code?

<?php

$i = "";

while ($i)

print "hi";

while($i < 8)

$i++;

print "hello";

?>

a) Hi is printed 8 times, hello 7 times and then hi 2 times

b) Hi is printed 10 times, hello 7 times

c) Hi is printed once, hello 7 times

d) Hi is printed once, hello 7 times and then hi 2 times

Answer: d

683. What will be the output of the following PHP code?

<?php

$i = 0;

while($i = 10)

print "hi";

print "hello";

?>

a) hello
b) infinite loop

c) hihello

d) error

Answer: b

684. What will be the output of the following PHP code?

<?php

$i = "";

while ($i = 10)

print "hi";

print "hello";

?>

a) hello

b) infinite loop

c) hihello

d) error

Answer: b

685. What will be the output of the following PHP code?

<?php

$i = 5;

while (--$i > 0)

$i++; print $i; print "hello";

?>

a) 4hello4hello4hello4hello4hello…..infinite
b) 5hello5hello5hello5hello5hello…..infinite

c) no output

d) error

Answer: b

686. What will be the output of the following PHP code?

<?php

$i = 5;

while (--$i > 0 && ++$i)

print $i;

?>

a) 5

b) 555555555…infinitely

c) 54321

d) error

Answer: b

687. What will be the output of the following PHP code?

<?php

$i = 5;

while (--$i > 0 || ++$i)

print $i;

?>

a) 54321111111….infinitely

b) 555555555…infinitely
c) 54321

d) 5

Answer: a

688. What will be the output of the following PHP code?

<?php

$i = 0;

while(++$i || --$i)

print $i;

?>

a) 1234567891011121314….infinitely

b) 01234567891011121314…infinitely

c) 1

d) 0

Answer: a

689. What will be the output of the following PHP code?

<?php

$i = 0;

while (++$i && --$i)

print $i;

?>

a) 1234567891011121314….infinitely

b) 01234567891011121314…infinitely
c) no output

d) error

Answer: c

690. What will be the output of the following PHP code?

<?php

$i = 0;

while ((--$i > ++$i) - 1)

print $i;

?>

a) 00000000000000000000….infinitely

b) -1-1-1-1-1-1-1-1-1-1…infinitely

c) no output

d) error

Answer: a

691. What will be the output of the following PHP code?

<?php

$i = 2;

while (++$i)

while ($i --> 0)

print $i;

?>

a) 210
b) 10

c) no output

d) infinite loop

Answer: a

692. What will be the output of the following PHP code?

<?php

$i = 2;

while (++$i)

while (--$i > 0)

print $i;

?>

a) 210

b) 10

c) no output

d) infinite loop

Answer: d

693. What will be the output of the following PHP code?

<?php

$i = 0;

for ($i)

print $i;

?>

a) 0
b) infinite loop

c) no output

d) error

View Answer

Answer: d

694. What will be the output of the following PHP code?

<?php

$colors = array("red","green","blue","yellow");

foreach ($colors as $value)

echo "$value <br>";

?>

a)

red

green

blue

yellow

b) red

c) no output

d) error

Answer: a

695. What will be the output of the following PHP code?

<?php

for ($x = 0; $x <= 10; $x++)


{

echo "The number is: $x <br>";

?>

a)

The number is: 0

The number is: 1

The number is: 2

The number is: 3

The number is: 4

The number is: 5

The number is: 6

The number is: 7

The number is: 8

The number is: 9

The number is: 10

b) The number is: 0

c) no output

d) error

Answer: a

696. What will be the output of the following PHP code?

<?php

for ($x = 0; $x <= 10; print ++$x)

print ++$x;

}
?>

a) 123456789101112

b) 12345678910

c) 1234567891011

d) infinite loop

Answer: a

697. What will be the output of the following PHP code?

<?php

for ($x = 1; $x < 10;++$x)

print "*\t";

?>

a) **********

b) *********

c) ***********

d) infinite loop

Answer: b

698. What will be the output of the following PHP code?

<?php

for ($x = -1; $x < 10;--$x)

print $x;

?>

a) 123456789101112

b) 12345678910

c) 1234567891011
d) infinite loop

Answer: d

699. What will be the output of the following PHP code?

<?php

$x;

for ($x = -3; $x < -5; ++$x)

print ++$x;

?>

a) -3-4-5

b) -3-4

c) infinite loop

d) no output

Answer: d

700. What will be the output of the following PHP code?

<?php

for ($i++; $i == 1; $i = 2)

print "In for loop ";

print "After loop\n";

?>

a) In for loop

b) After for loop

c) In for loopAfter for loop

d) Infinite loop

Answer: c

701. What will be the output of the following PHP code?


<?php

for (1; $i == 1; $i = 2)

print "In for loop ";

print "After loop\n";

?>

a) In for loop

b) After for loop

c) In for loopAfter for loop

d) Infinite loop

Answer: b

702. What will be the output of the following PHP code?

<?php

for ($i == 2; ++$i == $i; ++$i)

print "In for loop ";

print "After loop\n";

?>

a) In for loopIn for loopIn for loopIn for loop……infinitely

b) After for loopAfter for loopAfter for loop……..infinitely

c) In for loopAfter for loopIn for loopAfter for loopIn for loopAfter for loop…..infinitely

d) After for loop

Answer: a

703. What will be the output of the following PHP code?

<?php

for ($x = 1; $x < 10; $x++)

for ($y = 1; $y < 5; $y++)

print "Hello";

?>
a) Hello….36 times

b) Hello….45 times

c) Hello….50 times

d) Hello….40 times

Answer: a

704. What will be the output of the following PHP code?

<?php

for ($count = 1; $count != 20;$count++)

print $count;

$count++;

?>

a) Infinite

b) 123…….20

c) 1357…19

d) 13579…21

Answer: a

705. What will be the output of the following PHP code?

<?php

for ($count = 1; $count < 20; $count++);

print $count;

?>

a) 20

b) 19

c) 12345678910….19

d) 12345678910….1920

Answer: a
706. What will be the output of the following PHP code?

<?php

for ($count = 0; $count < 3;$count++);

print "hi";continue;print "hello";

?>

a) hihihi

b) hihellohihellohihello

c) hellohellohello

d) hi

Answer: a

707. What will be the output of the following PHP code?

<?php

for ($count = 0; $count<3;$count++);

print "hi";break;print "hello";

?>

a) hihihi

b) hihellohihellohihello

c) hellohellohello

d) hi

Answer: d

708. What will be the output of the following PHP code?

<?php

for(++$i; ++$i; ++$i)

{
print $i;

if ($i == 4)

break;

?>

a) 24

b) 134

c) 1234

d) 1

Answer: a

709. What will be the output of the following PHP code?

<?php

for ($i = 0;$i = -1;$i = 1)

print $i;

if ($i != 1)

break;

?>

a) 0

b) infinite loop

c) -1

d) 1

Answer: c

710. What will be the output of the following PHP code?

<?php

for(;;)

{
print "10";

?>

a) 10

b) infinite loop

c) no output

d) error

Answer: b

711. What will be the output of the following PHP code?

<?php

for ($i = 0; $i < 3; $i++)

for($j = $i; $j > 0; $j--)

print " ";

for($k = $j; $k < 3; $k++)

print "*";

print "\n";

?>

a)

**

***

b)

***
**

c)

**

***

d) error

Answer: a

712. What will be the output of the following PHP code?

<?php

for ($i = 0; -5 ; $i++)

print"i";

if ($i == 3)

break;

?>

a) 0 1 2 3 4

b) 0 1 2 3

c) 0 1 2 3 4 5

d) error

Answer: b

713. What will be the output of the following PHP code?

<?php

for ($i = 0; 0; $i++)

print"i";
}

?>

a) infinite loop

b) 0

c) no output

d) error

Answer: c

714. What will be the output of the following PHP code?

<?php

for ($i = 0; $i < 5; $i++)

for ($j = $i; $j > 0; $i--)

print $i;

?>

a) infinite loop

b) 0 1 2 3 4 5

c) 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0 1 2 3 4 5 0 1 2 3 4 5

d) no output

Answer: a

715. What will be the output of the following PHP code?

<?php

for ($i = 0; $i < 5; $i++)

for ($j = $i;$j > $i; $i--)

print $i;

?>
a) infinite loop

b) 0 1 2 3 4 5

c) 0 1 0 1 2 0 1 2 3 0 1 2 3 4 0 1 2 3 4 5 0 1 2 3 4 5

d) no output

Answer: d

716. What will be the output of the following PHP code?

<?php

$user = array("Ashley", "Bale", "Shrek", "Blank");

for ($x = 0; $x < count($user); $x++)

if ($user[$x] == "Shrek")

continue;

printf ($user[$x]);

?>

a) AshleyBaleBlank

b) AshleyBale

c) AshleyBaleShrek

d) No output

Answer: a

717. What will be the output of the following PHP code?

<?php

$user = array("Ashley", "Bale", "Shrek", "Blank");

for ($x=0; $x < count($user) - 1; $x++)

if ($user[$x++] == "Shrek")

continue;

printf ($user[$x]);
}

?>

a) AshleyBaleBlank

b) Bale

c) AshleyShrek

d) BaleBlank

Answer: a

718. What will be the output of the following PHP code?

<?php

$user = array("Ashley", "Bale", "Shrek", "Blank");

for ($x = 0; $x < count($user); $x)

if ($user[$x++] == "Shrek")

continue;

printf ($user[$x]);

?>

a) AshleyBaleBlank

b) BaleShrek

c) AshleyBlank

d) Bale

Answer: b

719. What will be the output of the following PHP code?

<?php

for ($i = 0; $i % ++$i; $i++)

{
print"i";

?>

a) error

b) infinite loop

c) no output

d) 0

Answer: b

720. What will be the output of the following PHP code?

<?php

for ($i = 0; $i < 5; $i++)

for(; $i < 5; $i++)

print"i";

?>

a) iiiii

b) infinite loop

c) iiiiiiiiiiiiiiiiiiiiiiiii

d) no output

Answer: a

721. What will be the output of the following PHP code?

<?php

$a = array("hi", "hello", "bye");

foreach ($a as $value)

if (count($a) == 2)
print $value;

?>

a) hihellobye

b) infinite loop

c) hihello

d) no output

Answer: d

722. What will be the output of the following PHP code?

<?php

$a = array("hi", "hello", "bye");

for (;count($a) < 5;)

if (count($a) == 3)

print $a;

?>

a) ArrayArrayArrayArrayArrayArray….infinitely

b) (“hi”,”hello”,”bye”)(“hi”,”hello”,”bye”)(“hi”,”hello”,”bye”)(“hi”,”hello”,”bye”)…infinitely

c) hihellobyehihellobyehihellobyehihellobyehihellobyehihellobye…..infinitely

d) no output

Answer: a

723. What will be the output of the following PHP code?

<?php

function calc($price, $tax="")

$total = $price + ($price * $tax);


echo "$total";

calc(42);

?>

a) Error

b) 0

c) 42

d) 84

Answer: c

724. What will be the output of the following PHP code?

<?php

function a()

function b()

echo 'I am b';

echo 'I am a';

a();

a();

?>

a) I am b

b) I am bI am a

c) Error

d) I am a Error

Answer: d
725. What will be the output of the following PHP code?

<?php

function a()

function b()

echo 'I am b';

echo 'I am a';

b();

a();

?>

a) I am b

b) I am bI am a

c) Error

d) I am a Error

Answer: c

726. What will be the output of the following PHP code?

<?php

$op2 = "blabla";

function foo($op1)

echo $op1;

echo $op2;

}
foo("hello");

?>

a) helloblabla

b) error

c) hello

d) helloblablablabla

Answer: c

727.What will be the output of the following PHP code?

<?php

function foo($msg)

echo "$msg";

$var1 = "foo";

$var1("will this work");

?>

a) error

b) $msg

c) 0

d) will this work

Answer: d

728. What will be the output of the following PHP code?

<?php

echo "chr(52)";

?>

a) 1
b) 2

c) 3

d) 4

Answer: d

729. What will be the output of the following PHP code?

<?php

echo ord ("hi");

?>

a) 106

b) 103

c) 104

d) 209

Answer: c

730. What will be the output of the following PHP code?

<?php

echo(atan(0.50));

?>

a) 0.11845976421345

b) 0.23568451142521

c) 0.46364760900081

d) 1

Answer: c

731. What will be the output of the following PHP code?

<?php

define("GREETING","Hello you! How are you today?");


echo constant("GREETING");

?>

a) Hello you! How are you today?

b) GREETING

c) GREETING, Hello you! How are you today?

d) “GREETING”,”Hello you! How are you today?”

Answer: a

732. What will be the output of the following PHP code?

<?php

define("GREETING1","Hello you! How are you today?");

define("GREETING2","Hello you! How are you today?");

define("GREETING3","Hello you! How are you today?");

echo defined("GREETING");

?>

a) 1

b) 0

c) 3

d) 4

Answer: b

733. What will be the output of the following PHP code?

<?php

function sum($num1, $num2)

$total = $num1 + $num2;

echo "chr($total)";

$var1 = "sum";
$var1(5, 44);

?>

a) Error

b) 49

c) 1

d) Sum

Answer: c

734. What will be the output of the following PHP code?

<?php

function sum($num1, $num2)

$total = $num1 + $num2;

echo "cos($total)";

sum(5,-5);

?>

a) 0

b) 1

c) 0.5

d) -0.5

Answer: b

735. What will be the output of the following PHP code?

<?php

function b()

echo "b is executed";


}

function a()

b();

echo "a is executed";

b();

a();

?>

a) b is executedb is executedb is executed

b) b is executeda is executed

c) a is executed

d) b is executeda is executedb is executed

Answer: d

736. What will be the output of the following PHP code?

<?php

function sum($x, $y)

$z = $x + $y;

return $z;

echo "5 + 10 = " . sum(7,13) . "<br>";

echo "7 + 13 = " . sum(2,4) . "<br>";

echo "2 + 4 = " . sum(5,10);

?>

a)
5 + 10 = 15

2+4=6

7 + 13 = 20

b)

7 + 13 = 20

5 + 10 = 15

2+4=6

c)

5 + 10 = 15

7 + 13 = 20

2+4=6

d)

5 + 10 = 20

7 + 13 = 6

2 + 4 = 15

Answer: d

737. What will be the output of the following PHP code?

<?php

function addFive($num)

$num += 5;

function addSix(&$num)

{
$num += 6;

$orignum = 10;

addFive( &$orignum );

echo "Original Value is $orignum<br />";

addSix( $orignum );

echo "Original Value is $orignum<br />";

?>

a)

Original Value is 15

Original Value is 21

b)

Original Value is 15

Original Value is 21

c)

Original Value is 15

Original Value is 15

d) None Of The mentioned

Answer: b

738. What will be the output of the following PHP code?

<?php

function addFunction($num1, $num2)

$sum = $num1 + $num2;


return $sum;

$return_value = addFunction(10, 20);

echo "Returned value from the function : $return_value"

?>

a) Returned value from the function : $return_value

b) Error

c) Returned value from the function : 30

d) Returned value from the function :

Answer: c

739. What will be the output of the following PHP code?

<?php

function sayHello()

echo "HelloWorld<br />";

$function_holder = "sayHello";

$function_holder();

?>

a) No Output

b) Error

c) sayHello

d) HelloWorld

Answer: d

740. What will be the output of the following PHP code?

<?php
function one()

echo " this works";

function two()

echo "this too works";

one();

two();

?>

a) error

b) this works

c) this worksthis too works

d) this works this too works

Answer: c

741. What will be the output of the following PHP code?

<?php

function do($myString)

echo strpos($myString, "donkey",0);

do("The donkey looks like a horse.");

?>

a) 4

b) 5

c) 2
d) None of the mentioned

Answer: a

742. What will be the output of the following PHP code?

<?php

function one()

define("const","I am awesome!");

echo constant("const");

one();

?>

a) I am awesome!!

b) const

c) const, I am awesome!!

d) “const”,”I am awesome!”

Answer: a

743. What will be the output of the following PHP code?

<?php

$title = "O'malley wins the heavyweight championship!";

echo ucwords($title);

?>

a) O’Malley Wins The Heavyweight Championship!

b) O’malley Wins The Heavyweight Championship!

c) O’Malley wins the heavyweight championship!

d) o’malley wins the heavyweight championship!

Answer: d
744. What will be the output of the following PHP code?

<?php

echo str_pad("Salad", 5)." is good.";

?>

a) SaladSaladSaladSaladSalad is good

b) is good SaladSaladSaladSaladSalad

c) is good Salad

d) Salad is good

Answer: d

745. What will be the output of the following PHP code?

<?php

$str = "Hello World"

echo wordwrap($str,5,"<br>\n");

?>

a) Hello World

b)

Hello

World

c)

Hell

o wo

rld

d) World

Answer: b
746. What will be the output of the following PHP code?

<?php

echo ucwords("i love my country");

?>

a) I love my country

b) i love my Country

c) I love my Country

d) I Love My Country

Answer: d

747. What will be the output of the following PHP code?

<?php

echo lcfirst("welcome to India");

?>

a) welcome to India

b) welcome to india

c) Welcome to India

d) Welcome to india

Answer: a

748. What will be the output of the following PHP code?

<?php

echo hex2bin("48656c6c6f20576f726c6421");

?>

a) Hello World!

b) welcome to india

c) This is PHP!
d) MCQ questons

Answer: a

749. What will be the output of the following PHP code?

<?php

$str = addslashes('What does "yolo" mean?');

echo($str);

?>

a) What does /”yolo/” mean?

b) What does \\”yolo\\” mean?

c) What does \”yolo\” mean?

d) \What does \”yolo\” mean?\

Answer: c

750. What will be the output of the following PHP code?

<?php

$str = "Hello world. It's a beautiful day.";

print_r (explode(" ",$str));

?>

a) Array ( *0+ => Hello *0+ => world. *0+ => It’s *0+ => a *0+ => beautiful *0+ => day. )

b) Array ( *0+ => Hello *1+ => world. *2+ => It’s *3+ => a *4+ => beautiful *5+ => day. )

c) Hello world. It’s a beautiful day

d) Array ( [1] => Hello [2] => world. [3+ => It’s *4+ => a *5+ => beautiful *6+ => day. )

Answer: b

751. What will be the output of the following PHP code?

<?php

echo strtr("Hilla Warld","ia","eo");


?>

a) Hilla Warld

b) Hello World

c) ia

d) eo

Answer: b

752. What will be the output of the following PHP code?

<?php

echo stripos("I love php, I love php too!","PHP");

?>

a) 3

b) 7

c) 8

d) 10

Answer: b

753. What will be the output of the following PHP code?

<?php

function A1($x)

switch($x)

case 1:

//this statement is the same as if($x == 1)

echo 'Case 1 was executed.';

break;

case 2:
//this statement is the same as if($x == 2)

echo 'Case 2 was executed.';

break;

case 3:

//this statement is the same as if($x == 3)

echo 'Case 3 was executed.';

break;

case 4:

//this statement is the same as if($x == 4)

echo 'Case 4 was executed.';

break;

default:

//this statement is the same as if $x does not equal the other conditions

echo 'Default was executed.';

break;

A1(9);

?>

a) Case 1 was executed

b) Case 2 was executed

c) Default was executed

d) Case 4 was executed

Answer: d

754. What will be the output of the following PHP code?

<?php
function uppercase($string)

echo ucwords($string);

$wow = "uppercase";

$wow("Time to live king size");

?>

a) TIME TO LIVE KING SIZE

b) Time to live king size

c) Uppercase

d) Time To Live King Size

Answer: d

755. What will be the output of the following PHP code?

<?php

function TV($string)

echo "my favourite TV show is ".$string;

function b()

echo " I am here to spoil this code";

b();

?>

a) I am here to spoil this code

b) Error

c) My favourite TV show isI am here to spoil this code


d) None of the mentioned

Answer: b

756. What will be the output of the following PHP code?

<?php

function TV($string)

echo "my favourite TV show is ".$string;

function b()

echo " I am here to spoil this code";

function b()

echo " I am here to spoil this code";

b();

?>

a) I am here to spoil this code

b) Error

c) my favourite TV show isI am here to spoil this code

d) None of the mentioned

Answer: a

757. What will be the output of the following PHP code?

<?php

function TV($string)
{

echo "my favourite TV show is ".$string;

function b()

echo " I am here to spoil this code";

function b()

echo " I am here to spoil this code";

b();

TV("Sherlock");

?>

a) I am here to spoil this code

b) Error

c) My favourite TV show isI am here to spoil this code

d) None of the mentioned

Answer: b

758. What will be the output of the following PHP code?

<?php

function TV($string)

echo "my favourite TV show is ".$string;

function b()

echo " I am here to spoil this code";


}

a("Sherlock");

b();

?>

a) I am here to spoil this code

b) Error

c) my favourite TV show is SherlockI am here to spoil this code

d) None of the mentioned

Answer: c

759. What will be the output of the following PHP code?

<?php

function calc($num1, $num2)

$total = $num1 * $num2;

$result = calc(42, 0);

echo $result;

?>

a) Error

b) 0

c) 42

d) 84

Answer: a

760. What will be the output of the following PHP code?

<?php
function calc($num1, $num2)

$total = $num1 * $num2;

return $total;

$result = calc(42, 0);

echo $result;

?>

a) Error

b) 0

c) 42

d) 84

Answer: b

761. What will be the output of the following PHP code?

<?php

$var = 10;

function one()

echo $var;

one();

?>

a) Error

b) 10

c) No Output

d) None of the Mentioned

Answer: c
762. What will be the output of the following PHP code?

<?php

function mine($m)

if ($m < 0)

echo "less than 0";

if ($ >= 0)

echo "Not True";

mine(0);

?>

a) Less Than 0

b) Not True

c) No Output

d) None of the Mentioned

Answer: b

763. What will be the output of the following PHP code?

<?php

$x = 75;

$y = 25;

function addition()

$GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y'];

addition();

echo $z;

?>
a) 100

b) error

c) 75

d) 25

Answer: a

764. What will be the output of the following PHP code?

<?php

function 2myfunc()

echo "Hello World";

2myfunc();

?>

a) Hello World

b) No Output

c) ERROR

d) None of the mentioned

Answer: c

765. What will be the output of the following PHP code?

<?php

function _func()

echo "Hello World";

_func();

?>
a) Hello World

b) No Output

c) ERROR

d) None of the mentioned

Answer: a

766. What will be the output of the following PHP code?

<?php

function test($int)

if ($int == 1)

echo "This Works";

if ($int == 2)

echo "This Too Seems To Work";

test(1);

TEST(2);

?>

a) This Works

b) This Too Seems To Work

c) This WorksThis Too Seems To Work

d) ERROR

Answer: c

767. What will be the output of the following PHP code?

<?php

function mine($num)

$num = 2 + $num;

echo $num;
}

mine(3);

?>

a) 3

b) $num

c) 5

d) None of the mentioned

Answer: c

768. What will be the output of the following PHP code?

<?php

function mine($num)

$num = 2 + $num;

echo "$num";

mine(3);

?>

a) 3

b) $num

c) 5

d) None of the mentioned

Answer: b

769. What will be the output of the following PHP code?

<?php

function one($string)

{
echo "I am ". $String;

one("Batman");

?>

a)

am Batman

b) I am

c) Batman

d) ERROR

Answer: d

770. What will be the output of the following PHP code?

<?php

function string($title);

$title = ucwords($title);

echo lcfirst($title);

string("you went full retard");

?>

a) You went full retard

b) You Went Full Retard

c) YOU WENT FULL RETARD

d) you Went Full Retard

Answer: d

771. What will be the output of the following PHP code?


<?php

function multi($num)

if ($num == 3)

echo "I Wonder";

if ($num == 7)

echo "Which One";

if ($num == 8)

echo "Is The";

if ($num == 19)

echo "Correct Answer";

$can = stripos("I love php, I love php too!","PHP");

multi($can);

?>

a) I Wonder

b) Which One

c) Is The

d) Correct Answer

Answer: b

772. What will be the output of the following PHP code?

<?php

function movie($int)

$movies = array("Fight Club", "Kill Bill", "Pulp Fiction");

echo "You Do Not Talk About ". $movie[$integer];


}

movie(0);

?>

a) You Do Not Talk About Fight Club

b) You Do Not Talk About Kill Bill

c) You Do Not Talk About Pulp Fiction

d) None of the mentioned

Answer: a

773. What will be the output of the following PHP code?

<?php

function colour()

$colors = array("red", "green", "blue", "yellow");

foreach ($colors as $value)

echo "$value <br>";

colour();

?>

a)

red

green

blue

yellow

b)
green

blue

yellow

red

c)

red

blue

yellow

green

d)

red

green

yellow

blue

Answer: a

774. What will be the output of the following PHP code?

<?php

function addFunction($num1, $num2)

$sum = $num1 + $num2;

return $sum;

$return_value = addFunction(10, 20);

echo "Returned value from the function : " .$return_value


?>

a) Returned value from the function : $return_value

b) Error

c) Returned value from the function : 30

d) Returned value from the function :

Answer: c

775. What will be the output of the following PHP code?

<?php

function time($string)

echo strtr("Towe Pa55", "ow5", $string);

time("ims");

?>

a) Time Pa55

b) Towe Pa55

c) Towe Pass

d) Time Pass

Answer: d

776. What will be the output of the following PHP code?

<?php

function constant()

define("GREETING", "Welcome to Narnia");

echo greeting;

}
?>

a) Welcome to Narnia

b) greeting

c) GREETING

d) ERROR

Answer: d

777. What will be the output of the following PHP code?

<?php

function constant()

define("GREETING", "Welcome to Narnia",true);

echo greeting;

?>

a) Welcome to Narnia

b) greeting

c) GREETING

d) ERROR

Answer: a

778. What will be the output of the following PHP code?

<?php

function start($string)

if ($string < 45)

return 20;

else
return 40;

$t = start(90);

if ($t < 20)

echo "Have a good day!";

else

echo "Have a good night!";

?>

a) Have a good day!

b) Have a good night!

c) ERROR

d) None of the mentioned

Answer: b

779. What will be the output of the following PHP code?

<?php

function case()

ECHO "Hello World!<br>";

echo "Hello World!<br>";

EcHo "Hello World!<br>";

case();

?>
a) Hello World!

b)

Hello World!

Hello World!

c)

Hello World!

Hello World!

Hello World!

d) None of the mentioned

Answer: c

780. What will be the output of the following PHP code?

<?php

function email()

$email = ’user@yahoo.com’;

$new = strstr($email, ‘@');

echo $new;

email();

?>

a) user

b) user@yahoo.com

c) @yahoo.com

d) yahoo.com

Answer: c
781. What will be the output of the following PHP code?

<?php

function string()

echo strstr("Hello world!", 111);

string();

?>

a) o world!

b) Hello world!

c) 111

d) No Output

Answer: a

782. What will be the output of the following PHP code?

<?php

function CalAll($x,$y)

echo ($x + $y);

echo "<br>";

echo ($x - $y);

echo "<br>";

echo ($x * $y);

echo "<br>";

echo ($x / $y);

echo "<br>";

echo ($x % $y);


}

$x = 10;

$y = 6;

CalcAll();

?>

a)

60

1.6666666666667

16

b)

16

60

1.6666666666667

c)

16

60

1.6666666666667

d)
1.6666666666667

16

60

Answer: b

You might also like