PHP PDF
PHP PDF
c) Only ii)
Answer: d
a) .html
b) .xml
c) .php
d) .ph
Answer: c
c) <? ?>
d) <?php ?>
Answer: c
i) Notepad
ii) Notepad++
iv) PDT
a) Only iv)
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
iv) IIS
b) Only ii)
Answer: d
a) PHP 4
b) PHP 5
c) PHP 6
Answer: d
i) /?
ii) //
iii) #
iv) /* */
a) Only ii)
Answer: c
8. Which of the following PHP statement/statements will store 111 in variable num?
c) Only iii)
d) Only i)
Answer: c
<?php
$num = 1;
$num1 = 2;
?>
a) 3
b) 1+2
c) 1.+.2
d) Error
Answer: b
<?php
$num = "1";
$num1 = "2";
print $num+$num1;
?>
a) 3
b) 1+2
c) Error
d) 12
Answer: a
i) $3hello
ii) $_hello
iii) $this
iv) $This
a) Only ii)
b) Only iii)
Answer: d
<?php
$foo = 'Bob';
$bar = &$foo;
echo $bar;
echo $foo;
?>
a) Error
b) My name is BobBob
Answer: c
13. Which of the following PHP statements will output Hello World on the screen?
a) i) and ii)
Answer: b
<?php
$color = "maroon";
$var = $color[2];
echo "$var";
?>
a) a
b) Error
c) $var
d) r
Answer: d
<?php
$score = 1234;
echo $scoreboard[0];
?>
a) 1
b) Error
c) 1234
d) 2
Answer: c
<?php
$more = 10;
echo "$total";
?>
a) Error
b) 35 students
c) 35
d) 25 students
Answer: c
a) $add = $add
c) $add = $add + 1
Answer: b
a) echo “\$x”;
b) echo “$$x”;
c) echo “/$x”;
d) echo “$x;”;
Answer: a
<?php
function track() {
static $count = 0;
$count++;
echo $count;
track();
track();
track();
?>
a) 123
b) 111
c) 000
d) 011
Answer: a
<?php
$a = "clue";
$a .= "get";
echo "$a";
?>
a) get
b) true
c) false
d) clueget
Answer: d
<?php
$a = 5;
$b = 5;
?>
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
<?php
$num = 10;
?>
Answer: a
i) if statements
a) Only i)
Answer: d
<?php
$team = "arsenal";
switch ($team) {
case "manu":
case "arsenal":
case "manc":
?>
a) I love arsenal
b) Error
Answer: c
i) for loop
a) i) and ii)
Answer: c
<?php
printf ($user[$x]);
?>
a) AshleyBale
b) AshleyBaleBlank
c) ShrekBlank
d) Shrek
Answer: b
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
$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
a) Rasmus Lerdorf
b) Willam Makepiece
c) Drek Kolkevi
d) List Barely
Answer: a
Answer: d
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)
$pricetag = 15;
$taxtag = 3;
calc($pricetag, $taxtag);
?>
a) Call By Value
b) Call By Reference
d) Type Hinting
Answer: a
<?php
echo "$total";
calc(42);
?>
a) Error
b) 0
c) 42
d) 84
Answer: c
ii) €()
iii) .function()
iv) $function()
a) Only i)
b) Only ii)
c) i) and ii)
Answer: b
<?php
function a()
function b()
a();
a();
?>
a) I am a
b) I am bI am a
c) Error
d) I am a Error
Answer: a
function a()
function b()
b();
a();
?>
a) I am b
b) I am bI am a
c) Error
d) I am a Error
Answer: c
<?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
Answer: a
<?php
function foo($msg)
echo "$msg";
$var1 = "foo";
?>
a) Error
b) $msg
c) 0
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
<?php
echo chr(52);
?>
a) 1
b) 2
c) 3
d) 4
Answer: d
<?php
?>
a) 106
b) 103
c) 104
d) 209
Answer: c
<?php
echo wordwrap($str,5,"<br>\n");
?>
a) Hello World
b)
Hello
World
c)
Hell
o wo
rld
d) World
Answer: b
<?php
?>
a) I love my country
b) i love my Country
c) I love my Country
d) I Love My Country
Answer: d
<?php
?>
a) welcome to India
b) welcome to india
c) Welcome to India
d) Welcome to india
Answer: a
a) 1
b) 2
c) 0
d) -1
Answer: c
i) state[0] = "karnataka";
c) Only i)
Answer: a
<?php
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
<?php
"Andhra Pradesh");
?>
a) True
b) 1
c) False
d) 2
Answer: d
<?php
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
<?php
"banana");
?>
a) 3
b) 4
c) 5
d) 6
Answer: d
a) count()
b) array_count()
c) array_count_values()
d) count_values()
Answer: c
<?php
$cars = array("Volvo", "BMW", "Toyota");
echo "I like " . $cars[2] . ", " . $cars[1] . " and " . $cars[0] . ".";
?>
Answer: d
<?php
$c = array_combine($age, $fname);
print_r($c);
?>
d) Array ([35] => Peter [37] => Ben [43] => Joe)
Answer: d
<?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));
?>
Answer: d
<?php
$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");
$a2 = array("e" => "red", "f" => "green", "g" => "blue", "h" => "orange");
print_r($result);
?>
Answer: a
<?php
$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
<?php
echo array_shift($a);
echo "<br>";
array_pop($a);
print_r($a);
?>
a)
india
b)
india
c)
china
d)
china
<?php
print_r($a2);
echo "<br>";
print_r($b1);
?>
a)
Array ( [1] => hello [4] => hello [5] => php )
b)
Array ( [1] => hello [2] => hello [3] => hello [4] => hello )
c)
Array ( [1] => hello [2] => hello [3] => hello [4] => hello [5] => php )
d)
Array ( [1] => hello [2] => hello [3] => hello [4] => hello )
Answer: c
echo $names[0] . "is the brother of " . $names[1] . " and " . $names[1] . ".";
?>
d) Error
Answer: b
<?php
?>
c) $brother
d) Error
Answer: d
<?php
array_pop($place);
$place1 = array("Paris");
print_r($place);
?>
c) Array ( [0] => NYC [1] => LA [2] => Paris [3] => Paris )
Answer: b
<?php
array_pop($age);
print_r(array_change_key_case($age, CASE_UPPER));
?>
Answer: c
<?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 )
d) Array ( [a] => red [b] => green [c] => blue [d] => yellow )
Answer: c
<?php
$a1 = array("a" => "red", "b" => "green", "c" => "blue", "d" => "yellow");
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
<?php
$a = array(12, 5, 2);
echo(array_product($a));
?>
a) 024
b) 120
c) 010
d) 060
Answer: b
<?php
?>
a) a
b) b
c) c
d) d
Answer: c
<?php
print_r(array_replace($city_west, $city_east));
?>
Answer: d
<?php
echo pos($people);
?>
a) Lucy
b) Peter
c) Susan
d) Edmund
Answer: b
<?php
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 )
Answer: a
<?php
print_r($array);
?>
a) Array ( [0] => red [1] => green [2] => blue [3] => yellow )
b) Array ( [0] => blue [1] => yellow [2] => red [3] => green )
Answer: a
<?php
$age = array("Harry" => "21", "Ron" => "19", "Malfoy" => "23");
ksort($age);
echo "<br>";
?>
a)
Key = Harry, Value = 21
b)
c)
d)
Answer: c
<?php
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
?>
Answer: b
<?php
print_r(array_change_key_case($age, CASE_UPPER));
?>
Answer: c
<?php
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
<?php
$c = array_combine($fname, $age);
print_r($c);
?>
c) Array ( 35 37 43 )
d) Array ( “*Peter+ => 35” “*Ben+ => 37” “*Joe+ => 43” )
Answer: b
<?php
print_r(array_count_values($a));
?>
Answer: a
<?php
print_r($result);
?>
Answer: a
<?php
print_r($a1);
echo "<br>";
print_r($b1);
?>
a)
b)
Array ( [4] => blue [5] => blue [6] => blue)
c)
Array ( [3] => blue [4] => blue [5] => blue [6] => blue )
Array ()
d)
Array ( [3] => blue [4] => blue [5] => blue [6] => blue )
Answer: d
88. What will be the output of the following PHP code?
<?php
print_r(array_merge($a1, $a2));
?>
b) Array ( [0] => blue [1] => yellow [2] => red [3] => green )
c) Array ( [0] => red [1] => green [2] => blue [3] => yellow )
Answer: c
<?php
echo array_shift($a);
print_r ($a);
?>
a) green
b) red
Answer: d
<?php
array_pop($a);
print_r($a);
?>
a) Array ( [0] => red [1] => green )
Answer: a
<?php
$fruits = array_flip($fruits);
echo ($fruits[0]);
?>
a) mango
b) error
c) peach
d) 0
Answer: b
a) sort()
b) asort()
c) rsort()
d) dsort()
Answer: c
<?php
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
<?php
"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
<?php
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
<?php
"orange");
print_r ($subset);
?>
b) Array ( [0] => apple [1] => mango [2] => peach )
d) Array ( [0] => peach [1] => pear [2] => orange )
Answer: d
<?php
"orange");
print_r ($fruits);
?>
a) Error
b) Array ( [0] => apple [1] => mango [2] => peach )
Answer: c
<?php
?>
a) 4hello2
b) 4
c) 2
d) 6
Answer: d
<?php
print_r ($inter);
?>
a) Array ( [0] => KA [1] => LA [2] => CA [3] => MA [4] => TA [5] => IA [6] => GA )
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;
Answer: c
106. Which one of the following is the right way to define a constant?
a) constant 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?
a) Only ii)
b) Only iv)
c) i) and ii)
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)
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?
a) ii)
b) ii) and iii)
Answer: c
a) classname()
b) _construct()
c) function _construct()
d) function __construct()
Answer: d
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
<?php
class Example
public $name;
function Sample()
?>
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
iii) Namespaces
a) i)
b) ii)
c) i) and ii)
Answer: c
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);
c) destinationObject = _clone(targetObject);
d) destinationObject = clone(targetObject);
Answer: b
124. The class from which the child class inherits is called ________
i) Child class
a) Only i)
c) Only iii)
Answer: d
i) Abstract classes in PHP are declared with the help of abstract keyword.
iii) It is a class that really isn’t supposed to ever be instantiated but instead serves as a base class.
a) Only i)
b) Only iii)
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
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
a) __call
b) __invoke
c) __wakeup
d) __unset
Answer: a
a) 14
b) 15
c) 16
d) 17
Answer: c
b) Near-fatal error
c) Compile-time error
Answer: a
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
Answer: d
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
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
a) PHP 4
b) PHP 5
c) PHP 5.1
d) PHP 5.3
Answer: d
c) new 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
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
Answer: a
148. How many predefined exceptions does SPL provide access to?
a) 13
b) 14
c) 15
d) 16
Answer: a
i) BadFunctionCallException
ii) BadMethodCallException
iii) LogicException
iv) DomainException
a) Only ii)
b) Only iii)
d) Only iv)
Answer: c
i) OutOfBoundException
ii) OutOfRangeException
iii) OverflowException
iv) UnderflowException
a) i)
b) i) and iii)
c) i) and ii)
Answer: d
i) Cookies
a) Only ii)
c) Only iii)
Answer: d
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
<?php
$num = "123";
if (!filter_var($num, FILTER_VALIDATE_INT))
else
echo("Integer is valid");
?>
a) No output is returned
c) Integer is valid
d) Error
Answer: c
155. Which one of the following does not describe a validating filter?
<?php
$var=300;
else
echo("Integer is valid");
?>
a) No output is returned
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';
?>
a) FALSE
b) TRUE
c) NULL
d) ERROR
Answer: c
<?php
function convertSpace($string)
$string = "Peter_is_a_great_guy!";
?>
a) Peter_is_a_great_guy!
b) Peterisagreatguy!
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)
c) i) and iv)
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
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
<?php
$username = "jasoN";
if (ereg("([^a-z])",$username))
echo "Username must be all lowercase!";
else
?>
a) Error
d) No Output is returned
Answer: b
a) PHP 4
b) PHP 5
c) PHP 5.2
d) PHP 5.3
Answer: d
Answer: a
<?php
print_r(split("[\n\t]",$text));
?>
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)
i) \a
ii) \A
iii) \b
iv) \B
a) Only i)
b) i) and iii)
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
<?php
print_r($food);
?>
a) Array ( [0] => pasta [1] => steak [2] => fish [3] => 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)
c) only i)
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
echo ucwords($title);
?>
Answer: a
<?php
?>
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
<?php
$author = "nachiketh@example.com";
$author = str_replace("a","@",$author);
?>
d) Error
Answer: c
<?php
$url = "nachiketh@example.com";
?>
a) nachiketh@example.com
b) nachiketh
c) nachiketh@
d) example.com
Answer: d
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
<?php
?>
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?
Answer: a
195. What will be the output of the following code? (If say date is 22/06/2013.)
<?php
?>
b) Today is 22-06-2013
c) Today is 06-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?
Answer: d
a) 8
b) 9
c) 10
d) 11
Answer: b
b) 9
c) 10
d) 11
Answer: d
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);
Answer: c
205. What will be the output of the following PHP code if date is 24/02/2008?
<?php
echo $date->format('l,F,js,Y');
?>
b) Sunday, 02 24 2008
c) Sunday, 24 02 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
i) listAbbreviations()
ii) getName()
iii) getOffset()
iv) listIdentifiers()
a) Only i)
b) Only ii)
c) i) and iv)
Answer: c
i) _construct()
ii) getName()
iii) getOffset()
iv) getTransitions()
a) Only i)
b) Only ii)
Answer: c
209. Which of the following statements can be used to add two months to the existing date?
a) $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?
Answer: b
212. The attack which involves the insertion of malicious code into a page frequented by other users is
known as _______________
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;
?>
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)
c) i) and iv)
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)
d) i) and iii)
Answer: a
a) header()
b) footer()
c) inset()
d) isset()
Answer: d
225. Which of the following are types of PHP authentication implementation methodologies?
b) i) 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.
b) File-based authentication
c) Data-based 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
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
a) i) and iv)
b) i) and iii)
Answer: c
230. Which is the most powerful authentication method among the four?
b) File-based authentication
c) Data-based 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
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?
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
a) 2
b) 3
c) 4
d) 5
Answer: d
a) is_file_uploaded()
b) is_uploaded_file()
c) file_uploaded(“filename”)
d) uploaded_file(“filename”)
Answer: b
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
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?
Answer: c
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
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
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
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
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']);
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
Answer: d
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?
Answer: b
262. Which one of the following statements should be used to disable the use of two classes
administrator and 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?
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
$number = array(0,1,two,three,four,5);
print_r($num);
?>
c) Array([1]=> 1)
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);?
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
<?php
if (preg_match("/name/"),$name)
if (preg_match("/are/"))
else
?>
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
<?php
$find = array('/is/','/coffee/');
$replace = array('/was/','/tea/');
?>
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
<?php
print_r($sen);
?>
d) Error
Answer: c
a) preg_match
b) preg_match_all
c) preg_matchall
d) preg_split
Answer: c
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
Answer: a
286. Which one of the following statements instantiates the mysqli class?
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?
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
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
a) commit()
b) undo()
c) mysqli_rollback()
d) rollback()
Answer: c
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
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
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
<?php
class ShopProductWriter
print $str;
}
}
$writer->write( $product1 );
?>
a) Error
Answer: d
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
<?php
class MyClass
}
class NotMyClass
$a = new MyClass;
?>
a)
bool(true)
bool(true)
b)
bool(false)
bool(false)
c)
bool(true)
bool(false)
d)
bool(false)
bool(true)
Answer: c
<?php
class ParentClass
$a = new MyClass;
?>
a)
bool(false)
bool(false)
b)
bool(true)
bool(true)
c)
bool(false)
bool(true)
d)
bool(true)
bool(false)
Answer: b
<?php
class MyClass
$a = new MyClass;
?>
a) bool(true)
b) bool(false)
c) error
Answer: a
<?php
interface MyInterface
$a = new MyClass;
var_dump($a instanceof MyClass);
?>
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
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
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
a) nothing
b) forward slash
c) backward slash
Answer: d
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
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
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?
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
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
a) const
b) con
c) constant
d) _constant
Answer: a
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?
d) Nothing
Answer: c
i) boolean
ii) integer
iii) float
iv) string
a) 1
b) 2
c) 3
d) 4
Answer: d
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
Answer: d
354. At least how many abstract methods must an abstract class contain?
a) None
b) One
c) Two
d) Five
Answer: b
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
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
class CopyMe {}
$second = $first;
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
Answer: b
356. What will be the output of the following PHP code? (Before the version PHP 5.2)
class StringThing {}
print $st;
b) Object id #1
Answer: b
class Person
function __toString() {
$desc = $this->getName();
return $desc;
print $person;
d) BOB
Answer: c
b) pseudo
c) external
d) copied
Answer: d
a) __get()
b) __isset()
c) __unset()
d) __undefined()
Answer: a
class Checkout
// calculate bill
}
a) PHP Fatal error: Class IllegalCheckout may not inherit from final class
Answer: d
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
i) classes
ii) functions
iii) variables
a) i)
b) ii)
c) 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
a) /
b) \
c) .
d) |
Answer: b
366. Output:
namespace main;
com\getinstance\util\Debug::helloWorld()
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()
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 {
Debug::helloWorld();
a) error
d) debug
Answer: a
369. Which one of the following statements is true for include_once() and require_once()?
Answer: d
370. Which one of the following statements is true for require() and require_once()?
a) They are functions
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
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()?
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
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
a) Code Duplication
b) Inheritance
c) Encapsulation
d) Polymorphism
Answer: a
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
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
a) Strong Aggregation
b) Composition
c) Abstraction
d) Inheritance
Answer: b
396. Which one of the following statements is true about sequence diagrams?
c) The vertical broken lines represent the lifetime of the class in the system
a) double-headed arrow
b) visibility symbols
c) single-headed arrow
d) double diamond
Answer: a
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
Answer: a
<?php
"Hello World"
?>
a) Error
b) Hello World
c) Nothing
Answer: c
<?php
?>
a) Error
b) Hello World
c) Nothing
Answer: a
<?php
<html>
Hello world
</html>
?>
a) 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.
<?php
?>
b)
Hello world1
Hello world2
Hello World3
c) Error
Answer: a
<?php
$color = "red";
echo "$color";
echo "$COLOR";
echo "$Color";
?>
a) redredred
b) redred
c) red
d) Error
Answer: c
<?php
?>
a) # Hello world
c) Hello world
d) Error
Answer: a
<?php
?>
a) Hello world
c) Nothing
d) Error
Answer: b
<?php
?>
a) Hello world
d) Error
Answer: d
<?php
<?php
?>
?>
a) HELLO WORLD
b) Hello world
c) Nothing
d) Error
Answer: d
<?php
$color = red;
echo "\$color";
?>
a) red
b) $color
c) \red
d) Error
Answer: b
<?php
/*
*/
?>
a) Hello world
b) Nothing
c) Error
d)
/*
Hello world
*/
Answer: b
<?php
$color = red;
?>
a) red red
b) red
c) error
d) nothing
Answer: c
<?php
$color1 = red;
$color2 = green;
echo "$color1"."$color2";
?>
a) red green
b) red
c) green
d) error
Answer: d
<?php
$color = "red";
$color = "green";
echo "$color";
?>
a) red
b) green
c) red green
d) error
Answer: b
<?php
$color1 = "red";
$color2 = "green";
?>
a) red
b) green
c) red green
d) redgreen
Answer: d
<?php
$color1 = "red";
$color2 = "green";
?>
a) redgreen
b) red green
c) 0
d) error
Answer: c
<?php
$color1 = "red";
$color2 = "red";
?>
a) redgreen
b) red green
c) 0
d) 1
Answer: c
<?php
$color1 = "red";
$color2 = "1";
?>
a) red1
b) red 1
c) 0
d) 1
Answer: d
<?php
$color1 = "1";
$color2 = "1";
?>
a) 11
b) 2
c) 0
d) 1
Answer: b
<?php
$color1 = "red";
$color2 = "1";
$color3 = "grey"
?>
a) 1grey
b) grey
c) 0
d) red1grey
Answer: a
<?php
$x = 5;
$y = 10;
$z = "$x + $y";
echo "$z";
?>
a) 15
b) 10 + 5
c) $z
d) $x + $y
Answer: b
<?php
$x = 4;
$y = 3;
$z = 1;
?>
a) 4 = 4 + 3 + 1
b) 8
c) 8 = 4 + 3 +1
d) Error
Answer: a
<?php
$x = 4;
$y = 3
$z = 1;
$z = $z + $x + $y;
echo "$z";
?>
a) $z
b) 15
c) 8
d) 1
Answer: c
<?php
$x = 3.3;
$y = 2;
echo $x % $y;
?>
a) 0
b) 1
c) 2
d) Error
Answer: b
<?php
$x = 10;
$y = 4;
$z = 3;
echo $x % $y % $z;
?>
a) 0
b) 1
c) 2
d) Error
Answer: c
$x = 10;
$y = 4;
$z = 3;
?>
a) 5
b) 3
c) 0
d) 1
Answer: a
<?php
$x = 30;
$y = 20;
$z = 10;
?>
a) 41
b) -4
c) -5
d) 51
Answer: d
<?php
$x = -1;
$y = 1;
$z = $x * $y + $z;
echo $z;
?>
a) Undefined variable z
b) -1
c)
Undefined variable z
-1
Answer: c
<?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
$x = 3.5;
$y = 2;
$z = 2;
echo $x / $y / $z;
?>
a) 1.75
b) 0.875
c) 3.5
d) Error
Answer: b
<?php
one = 1;
two = 2;
three = 3;
four = 4;
?>
a) 0.75
b) 0.05
c) 1.25
d) Error
Answer: d
<?php
$on$e = 1;
$tw$o = 2;
$thre$e = 3;
$fou$r = 4;
?>
a) 0.75
b) 0.05
c) 1.25
d) Error
Answer: d
<?php
$on_e = 1;
$tw_o = 2;
$thre_e = 3;
$fou_r = 4;
?>
a) 0.75
b) 0.05
c) 1.25
d) Error
Answer: c
<?php
$On_e = 1;
$tw_o = 2;
$thre_e = 3;
$fou_r = 4;
?>
a) 0.75
b) 0.05
c) 1.25
d) Error
Answer: a
<?php
echo $red;
?>
a) 0
b) Nothing
c) True
d) Error
Answer: b
<?php
$four4 = 4;
$three3 = 3;
$two2 = 2;
a) 4.5
b) 7
c) 3.5
d) Error
Answer: a
<?php
$4four = 4;
$3three = 3;
$2two = 2;
?>
a) 4.5
b) 7
c) 3.5
d) Error
Answer: d
<?php
int $one = 1;
echo "$one";
?>
a) 0
b) 1
c) $one
d) Error
Answer: d
<?php
var $one = 1;
var $two = 2;
?>
a) 1
b) 0
c) 0.5
d) Error
Answer: d
<?php
$bye = "Bye";
echo $hello;"$bye";
?>
a) Hello World
b) Bye
c) Hello worldBye
d) Error
Answer: a
$x;
echo "$x";
?>
a) 0
b) 1
c) Nothing
d) Error
Answer: c
<?php
$x = 5;
$x = 10;
echo "$x";
echo "$x";
?>
a) 1010
b) 105
c) 510
d) error
Answer: a
<?php
$x = 5;
{
echo "$x";
?>
a) 0
b) 5
c) Nothing
d) Error
Answer: b
<?php
$x = 5;
function fun()
echo "$x";
fun();
?>
a) 0
b) 5
c) Nothing
d) Error
Answer: c
<?php
$x = 5;
function fun()
$x = 10;
echo "$x";
fun();
echo "$x";
?>
a) 0
b) 105
c) 510
d) Error
Answer: b
<?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
<?php
$x = 4;
$y = 3;
$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
<?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
<?php
$x = 3, 4, 5, 6;
echo "$x";
?>
a) 3
b) 4
c) 6
d) Error
Answer: d
<?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
<?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";
?>
a) $winner\$looser
b) \$looser
c) \
d) $looser
Answer: d
<?php
$a = "$winner";
$b = "\\$looser";
?>
a) $winner\\$looser
b) \\$looser
c) \
d) $looser
Answer: c
<?php
$x = 5;
$y = 10;
function fun()
fun();
echo $y;
?>
a) 5
b) 10
c) 15
d) Error
Answer: c
<?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
<?php
function fun()
$x = 0;
echo $x;
$x++;
fun();
fun();
fun();
?>
a) 012
b) 123
c) 000
d) 111
Answer: c
<?php
function fun()
static $x = 0;
echo $x;
$x++;
}
fun();
fun();
fun();
?>
a) 012
b) 123
c) 111
d) Error
Answer: a
<?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
<?php
$x = 0;
function fun()
echo $GLOBALS['x'];
$x++;
fun();
fun();
fun();
?>
a) 000
b) 012
c) Nothing
d) Error
Answer: a
<?php
?>
a) Hello world
c)
Hello world
I am learning PHP
d) Error
Answer: c
<?php
?>
a) Hello world
c)
Hello world
I am learning PHP
d) Error
Answer: b
<?php
?>
c) Thiswasabadidea
d) Error
Answer: c
<?php
echo "This"."was"."a"."bad"."idea";
?>
c) Thiswasabadidea
d) Error
Answer: c
<?php
echo "This","was"|"a","bad"."idea";
?>
a) Thiswasabadidea
b) Thiswasbadidea
c) Thiswas a badidea
d) Thiswas abadidea
Answer: b
<?php
$one = "Hello";
$two = "World";
?>
a) Hello World
b) Hello
c) World
d) HelloWorld
Answer: d
<?php
$one = "Hello";
$two = "World";
echo "$one$two";
?>
a) HelloWorld
b) $one$two
c) Hello
d) Error
Answer: a
<?php
$one = "Hello";
$two = "World";
echo "$one"+"$two";
?>
a) HelloWorld
b) Hello+World
c) 0
d) Error
Answer: c
<?php
?>
a) This is India
b) This is India
c) This is
d) Error
Answer: b
<?php
?>
a) My car is a Volvo
b) My car is a BMW
c) My car is a Toyota
d) Error
Answer: a
<?php
?>
b) hello world
c) nothing
d) error
Answer: a
<?php
$one = 1;
print($one);
print $one;
?>
a) 01
b) 11
c) 10
d) Error
Answer: b
<?php
print $cars[2];
?>
a) Volvo
b) BMW
c) Toyota
d) Error
Answer: c
<?php
$one = "one";
$two = "two";
print($one$two);
?>
a) onetwo
b) one
c) nothing
d) error
Answer: d
<?php
$one = "one";
$two = "two";
print($one,$two);
?>
a) onetwo
b) one, two
c) one
d) error
Answer: d
<?php
$one = "one";
$two = "two";
print("$one$two");
?>
a) onetwo
b) $one$two
c) one
d) error
Answer: a
<?php
$one = "one";
$two = "two";
print($one==$two);
?>
a) true
b) false
c) nothing
d) error
Answer: c
<?php
$one = "one";
$two = "one";
print($one == $two);
?>
a) true
b) false
c) 1
d) error
Answer: c
<?php
?>
a) Hello world!
c)
Hello world!
d) Error
Answer: c
<?php
print("this"."was"."a"."bad"."idea");
?>
a) thiswasabadidea
c) nothing
d) error
Answer: a
<?php
echo "<br>"
echo GREETING;
?>
b)
GREETING
GREEtING
c) GREETING
d)
Answer: d
<?php
echo $GREETING;
?>
a) $GREETING
b) no output
d) GREETING
Answer: b
<?php
$changing_variable = 'test';
?>
a)
b) GREETING_TESt
d)
GREETING_TEST
Answer: a
<?php
class Constants
define('MIN_VALUE', '0.0');
define('MAX_VALUE', '1.0');
return self::MIN_VALUE;
return self::MAX_VALUE;
}
echo Constants::getMinValue();
echo Constants::getMaxValue();
?>
a) 0.01.0
b) 01
c) No output
d) ERROR
Answer: d
<?php
echo __LINE__;
?>
b) __LINE__
c) 2
d) ERROR
Answer: c
<?php
define('IF', 42);
?>
a) IF:42
b) No output
c) IF:
d) ERROR
Answer: d
<?php
define("OLD_BAD_NAME_CONSTANT", NEW_GOOD_NAME_CONSTANT);
echo NEW_GOOD_NAME_CONSTANT;
echo OLD_BAD_NAME_CONSTANT;
?>
a) I have a value
c) ERROR
d) I have a valueNEW_GOO_NAME_CONSTANTS
Answer: b
<?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
<?php
define("VAR_NAME","test");
${VAR_NAME} = "value";
echo VAR_NAME;
echo ${VAR_NAME};
?>
a) test
b) testtest
c) testvalue
Answer: c
<?php
class myObject { }
define('myObject::CONSTANT', 'test');
echo myObject::CONSTANT;
?>
a) test
b) error
c) myObject::CONSTANT
d) no output
Answer: b
<?php
$a = 10;
echo ++$a;
echo $a++;
echo $a;
echo ++$a;
?>
a) 11111213
b) 11121213
c) 11111212
d) 11111112
Answer: a
<?php
$a = 12;
--$a;
echo $a++;
?>
a) 11
b) 12
c) 10
d) error
Answer: a
<?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
<?php
$x = 1;
$y = 2;
if (++$x == $y++)
?>
a) no output
b) true 23
c) true 22
d) true 33
Answer: b
<?php
$y = 2;
$w = 4;
$y *= $w /= $y;
?>
a) 80.5
b) 44
c) 82
d) 42
Answer: d
<?php
$y = 2;
if ($y-- == ++$y)
echo $y;
?>
a) 2
b) 1
c) 3
d) no output
Answer: a
<?php
$y = 2;
if (**$y == 4)
echo $y;
}
?>
a) 4
b) 2
c) error at line2
d) no output
Answer: c
<?php
$y = 2;
echo $y;
?>
a) 1
b) 0
c) 2
d) no output
Answer: b
<?php
$y = 2;
echo $y;
?>
a) 1
b) 0
c) 2
d) no output
Answer: b
<?php
?>
a) 1
b) 0
c) error
d) no output
Answer: a
<?php
$auth = 1;
$status = 1;
?>
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;
print "hi";
print "hello";
?>
a) hello
b) infinite loop
c) hihello
d) error
Answer: b
<?php
$i = "";
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;
$i++;
print $i;
print "hello";
?>
a) 4hello4hello4hello4hello4hello…..infinite
b) 5hello5hello5hello5hello5hello…..infinite
c) no output
d) error
Answer: a
<?php
$i = 5;
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;
print $i;
?>
a) 54321111111….infinitely
b) 555555555…infinitely
c) 54321
d) 5
Answer: a
<?php
$i = 0;
while(++$i || --$i)
print $i;
?>
a) 1234567891011121314….infinitely
b) 01234567891011121314…infinitely
c) 1
d) 0
Answer: a
<?php
$i = 0;
print $i;
?>
a) 1234567891011121314….infinitely
b) 01234567891011121314…infinitely
c) no output
d) error
Answer: c
<?php
$i = 0;
print $i;
?>
a) 00000000000000000000….infinitely
b) -1-1-1-1-1-1-1-1-1-1…infinitely
c) no output
d) error
Answer: a
<?php
$i = 2;
while (++$i)
{
print $i;
?>
a) 210
b) 10
c) no output
d) infinite loop
Answer: a
<?php
$i = 2;
while (++$i)
print $i;
?>
a) 210
b) 10
c) no output
d) infinite loop
Answer: d
<?php
echo 5 * 9 / 3 + 9;
?>
a) 24
b) 3.7
c) 3.85
d) 0
Answer: a
<?php
echo 5 * 9 / 3 + 9
?>
a) 24
b) 3.7
c) 3.85
d) 0
Answer: a
<?php
$i = 0;
$j = 0;
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;
echo "true";
echo $j;
?>
a) 20
b) true0
c) 0
d) true20
Answer: b
<?php
$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
$a = 1; $b = 3;
$d = $a++ + ++$b;
echo $d;
?>
a) 5
b) 4
c) 3
d) error
Answer: a
<?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
<?php
$a = 10; $b = 10;
if ($a = 5)
$b--;
?>
a) 58
b) 59
c) 109
d) 108
Answer: b
<?php
$i = 0;
$x = $i++; $y = ++$i;
?>
a) 02
b) 12
c) 01
d) 21
Answer: a
<?php
$a = 5; $b = -7; $c =0;
?>
a) 16
b) 06
c) 15
d) 05
Answer: a
$b = 1; $c = 4; $a = 5;
$d = $b + $c == $a;
print $d;
?>
a) 5
b) 0
c) 10
d) 1
Answer: d
<?php
echo 5 * 9 / 3 + 9;
?>
a) 24
b) 3.7
c) 3.85
d) 0
Answer: a
<?php
$var1 = 1 + ++5;
echo $var1;
?>
a) no output
b) error
c) 6
d) 7
Answer: b
<?php
$var1 = 0;
echo $var1;
?>
a) 5
b) error
c) 6
d) 7
Answer: b
<?php
$var1 = 0;
$var1 = $var1++ + 5;
echo $var1;
?>
a) 5
b) error
c) 6
d) 7
Answer: a
<?php
$var1 = 0;
$var1 = ++$var1 + 5;
echo $var1;
?>
a) 5
b) error
c) 6
d) 7
Answer: c
<?php
$var1 = 0;
$var1 = $var1 + 5;
echo $var1++;
?>
a) 5
b) error
c) 6
d) 7
Answer: a
<?php
$var1 = 1;
?>
a) 1
b) 0
c) 2
d) 3
Answer: d
<?php
?>
a) 16
b) 06
c) 15
d) 05
Answer: a
<?php
$var1 = 3;
?>
a) 1
b) 0
c) 2
d) 3
Answer: a
<?php
$var1 = 3;
print ++$var++;
?>
a) 3
b) 4
c) 5
d) error
Answer: d
<?php
$i = 0; $j = 1; $k = 2;
?>
a) 1
b) true
c) false
d) 0
Answer: a
<?php
$i = 0;$j = 1;$k = 2;
?>
a) 1
b) no output
c) error
d) 0
Answer: b
<?php
$i = 0;$j = 1;$k = 2;
?>
a) 1
b) no output
c) error
d) 0
Answer: a
<?php
$a = 0x6db7;
print $a<<6;
?>
a) 1797568
b) no output
c) error
d) 0x6dc0
Answer: a
<?php
$a = 'a' ;
print $a * 2;
?>
a) 192
b) 2
c) error
d) 0
Answer: d
<?php
$a = '4' ;
print + + $a;
?>
a) no output
b) error
c) 5
d) 0
Answer: c
<?php
$a = '12345';
print "qwe{$a}rty";
?>
a) qwe12345rty
b) qwe{$a}rty
c) error
d) no output
Answer: a
<?php
$a = '12345';
print "qwe".$a."rty";
?>
a) qwe12345rty
b) qwe$arty
c) error
d) no output
Answer: a
<?php
$a = '12345';
echo 'qwe{$a}rty';
?>
a) qwe12345rty
b) qwe{$a}rty
c) error
d) no output
Answer: b
<?php
$a = '12345';
echo "qwe$arty";
?>
a) qwe12345rty
b) qwe$arty
c) qwe
d) error
Answer: c
<?php
$x;
if ($x)
print "hi" ;
else
?>
a) how are u
b) hi
c) error
d) no output
Answer: a
<?php
$x = 0;
if ($x++)
print "hi";
else
a) hi
b) no output
c) error
d) how are u
Answer: d
<?php
$x;
if ($x == 0)
print "hi" ;
else
print "hello"
?>
b) hihello
c) hi
d) no output
Answer: b
<?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
<?php
$a = 1;
if ($a--)
print "True";
if ($a++)
print "False";
?>
a) true
b) false
c) error
d) no output
Answer: a
<?php
$a = 1;
if (echo $a)
print "True";
else
print "False";
?>
a) true
b) false
c) error
d) no output
Answer: c
<?php
$a = 1;
if (print $a)
print "True";
else
print "False";
?>
a) true
b) false
c) error
d) no output
Answer: a
<?php
$a = 10;
if (1)
print "all";
else
print "some"
else
print "none";
?>
a) all
b) some
c) error
d) none
Answer: c
<?php
$a = 10;
if (0)
print "all";
if
else
print "some"
?>
a) all
b) some
c) error
d) no output
Answer: c
<?php
$a = "";
if ($a)
print "all";
if
else
print "some";
?>
a) all
b) some
c) error
d) no output
Answer: b
<?php
$a = "a";
if ($a)
print "all";
else
print "some";
?>
a) all
b) some
c) error
d) no output
Answer: a
<?php
$x = 10;
$y = 20;
if ($x > $y + $y != 3)
print "hi" ;
else
?>
a) how are u
b) hi
c) error
d) no output
Answer: b
<?php
$x = 10;
$y = 20;
print "hi" ;
else
?>
a) how are u
b) hi
c) error
d) no output
Answer: b
$x = 10;
$y = 20;
print "hi" ;
else
?>
a) how are u
b) hi
c) error
d) no output
Answer: b
<?php
if (-100)
print "hi" ;
else
?>
a) how are u
b) hi
c) error
d) no output
Answer: b
if (0.1)
print "hi" ;
else
?>
a) how are u
b) hi
c) error
d) no output
Answer: b
<?php
if (0.0)
print "hi" ;
else
?>
a) how are u
b) hi
c) error
d) no output
Answer: a
<?php
if (print "0")
print "hi" ;
else
?>
a) 0how are u
b) 0hi
c) hi
d) how are u
Answer: b
<?php
$x = 1;
if ($x == 2)
print "hi" ;
else if($x = 2)
print $x;
else
?>
a) error
b) 2
c) hi
d) how are u
Answer: b
<?php
$x = 1;
if ($x = $x&0)
print $x ;
else
?>
a) 0
b) 1
c) error
d) how are u
Answer: d
<?php
$x = 1;
if ($x = $x&0)
print $x ;
else
?>
a) 0
b) 1
c) error
d) how are u
Answer: d
<?php
$x = 1;
if ($x = $x&0)
print $x;
else
break;
?>
a) 0
b) 1
c) error
d) no output
Answer: c
<?php
$a = 100;
printf("M.S. Dhoni");
printf("M.E.K Hussey");
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
<?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
<?php
if (!print "hi")
if (print "hello")
print "hi";
?>
a) hi
b) hihellohi
c) hihi
d) no output
Answer: a
<?php
if (print "hi" - 1)
print "hello"
?>
a) hi
b) hihello
c) error
d) no output
Answer: c
<?php
$x = 1;
if ($x--)
print "hi"
$x--;
else
print "hello"
?>
a) hi
b) hello
c) error
d) no output
Answer: c
$a = 10;
$b = 11;
print "hello";
else
print "hi";
?>
a) hi
b) hello
c) error
d) no output
Answer: a
<?php
$a = 2;
print "hello";
else
print "hi";
?>
a) hi
b) hello
c) error
d) no output
Answer: b
$a = 2;
print "hello";
else
print "hi";
?>
a) hi
b) hello
c) error
d) no output
Answer: b
<?php
$a = "hello";
if ($a.length)
print $a.length;
else
print "hi";
?>
a) hellolength
b) 5
c) hi
d) error
Answer: a
$a = "hello";
if (strlen($a))
print strlen($a);
else
print "hi";
?>
a) hellolength
b) 5
c) hi
d) error
Answer: b
<?php
$a = "1";
$b = "0";
print"hi";
else
print "hello";
?>
a) hello
b) no output
c) hi
d) error
Answer: a
$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
<?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
<?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
<?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
<?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
<?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
<?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
<?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
<?php
switch($b)
{
case 2:
print "hello";
break;
case 1:
print "hi";
break;
?>
a) hello
b) hi
c) no output
d) error
Answer: c
<?php
switch($b)
case 2:
print "hello";
break;
case b:
print "hi";
break;
?>
a) hello
b) hi
c) no output
d) error
Answer: c
<?php
while()
print "hi";
?>
a) infinite loop
b) hi
c) no output
d) error
Answer: d
<?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++;
?>
a)
hi
hi
b) hi
c)
hi
hi
hi
hi
d) no output
Answer: c
<?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
<?php
$i = 0
{
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
<?php
$i = 0
$i++;
print $i;
?>
a) 2
b) 3
c) 0
d) 1
Answer: b
<?php
$i = 0
do
$i++;
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
<?php
$i = "";
while($i)
print "hi";
print "hello";
?>
a) hello
b) infinite loop
c) hihello
d) error
Answer: a
<?php
$i = "";
while ($i)
print "hi";
while($i < 8)
$i++;
print "hello";
?>
Answer: d
<?php
$i = 0;
while($i = 10)
print "hi";
print "hello";
?>
a) hello
b) infinite loop
c) hihello
d) error
Answer: b
<?php
$i = "";
print "hi";
print "hello";
?>
a) hello
b) infinite loop
c) hihello
d) error
Answer: b
<?php
$i = 5;
?>
a) 4hello4hello4hello4hello4hello…..infinite
b) 5hello5hello5hello5hello5hello…..infinite
c) no output
d) error
Answer: b
<?php
$i = 5;
print $i;
?>
a) 5
b) 555555555…infinitely
c) 54321
d) error
Answer: b
<?php
$i = 5;
print $i;
?>
a) 54321111111….infinitely
b) 555555555…infinitely
c) 54321
d) 5
Answer: a
<?php
$i = 0;
while(++$i || --$i)
print $i;
?>
a) 1234567891011121314….infinitely
b) 01234567891011121314…infinitely
c) 1
d) 0
Answer: a
<?php
$i = 0;
print $i;
?>
a) 1234567891011121314….infinitely
b) 01234567891011121314…infinitely
c) no output
d) error
Answer: c
<?php
$i = 0;
print $i;
?>
a) 00000000000000000000….infinitely
b) -1-1-1-1-1-1-1-1-1-1…infinitely
c) no output
d) error
Answer: a
<?php
$i = 2;
while (++$i)
print $i;
?>
a) 210
b) 10
c) no output
d) infinite loop
Answer: a
<?php
$i = 2;
while (++$i)
print $i;
?>
a) 210
b) 10
c) no output
d) infinite loop
Answer: d
<?php
$i = 0;
for ($i)
print $i;
?>
a) 0
b) infinite loop
c) no output
d) error
View Answer
Answer: d
<?php
$colors = array("red","green","blue","yellow");
?>
a)
red
green
blue
yellow
b) red
c) no output
d) error
Answer: a
<?php
?>
a)
c) no output
d) error
Answer: a
<?php
print ++$x;
}
?>
a) 123456789101112
b) 12345678910
c) 1234567891011
d) infinite loop
Answer: a
<?php
print "*\t";
?>
a) **********
b) *********
c) ***********
d) infinite loop
Answer: b
<?php
print $x;
?>
a) 123456789101112
b) 12345678910
c) 1234567891011
d) infinite loop
Answer: d
<?php
$x;
print ++$x;
?>
a) -3-4-5
b) -3-4
c) infinite loop
d) no output
Answer: d
<?php
for ($i++; $i == 1; $i = 2)
?>
a) In for loop
d) Infinite loop
Answer: c
for (1; $i == 1; $i = 2)
?>
a) In for loop
d) Infinite loop
Answer: b
<?php
?>
c) In for loopAfter for loopIn for loopAfter for loopIn for loopAfter for loop…..infinitely
Answer: a
<?php
print "Hello";
?>
a) Hello….36 times
b) Hello….45 times
c) Hello….50 times
d) Hello….40 times
Answer: a
<?php
print $count;
$count++;
?>
a) Infinite
b) 123…….20
c) 1357…19
d) 13579…21
Answer: a
<?php
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
?>
a) hihihi
b) hihellohihellohihello
c) hellohellohello
d) hi
Answer: a
<?php
?>
a) hihihi
b) hihellohihellohihello
c) hellohellohello
d) hi
Answer: d
<?php
{
print $i;
if ($i == 4)
break;
?>
a) 24
b) 134
c) 1234
d) 1
Answer: a
<?php
print $i;
if ($i != 1)
break;
?>
a) 0
b) infinite loop
c) -1
d) 1
Answer: c
<?php
for(;;)
{
print "10";
?>
a) 10
b) infinite loop
c) no output
d) error
Answer: b
<?php
print "*";
print "\n";
?>
a)
**
***
b)
***
**
c)
**
***
d) error
Answer: a
<?php
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
<?php
print"i";
}
?>
a) infinite loop
b) 0
c) no output
d) error
Answer: c
<?php
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
<?php
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
<?php
if ($user[$x] == "Shrek")
continue;
printf ($user[$x]);
?>
a) AshleyBaleBlank
b) AshleyBale
c) AshleyBaleShrek
d) No output
Answer: a
<?php
if ($user[$x++] == "Shrek")
continue;
printf ($user[$x]);
}
?>
a) AshleyBaleBlank
b) Bale
c) AshleyShrek
d) BaleBlank
Answer: a
<?php
if ($user[$x++] == "Shrek")
continue;
printf ($user[$x]);
?>
a) AshleyBaleBlank
b) BaleShrek
c) AshleyBlank
d) Bale
Answer: b
<?php
{
print"i";
?>
a) error
b) infinite loop
c) no output
d) 0
Answer: b
<?php
print"i";
?>
a) iiiii
b) infinite loop
c) iiiiiiiiiiiiiiiiiiiiiiiii
d) no output
Answer: a
<?php
if (count($a) == 2)
print $value;
?>
a) hihellobye
b) infinite loop
c) hihello
d) no output
Answer: d
<?php
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
<?php
calc(42);
?>
a) Error
b) 0
c) 42
d) 84
Answer: c
<?php
function a()
function b()
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()
b();
a();
?>
a) I am b
b) I am bI am a
c) Error
d) I am a Error
Answer: c
<?php
$op2 = "blabla";
function foo($op1)
echo $op1;
echo $op2;
}
foo("hello");
?>
a) helloblabla
b) error
c) hello
d) helloblablablabla
Answer: c
<?php
function foo($msg)
echo "$msg";
$var1 = "foo";
?>
a) error
b) $msg
c) 0
Answer: d
<?php
echo "chr(52)";
?>
a) 1
b) 2
c) 3
d) 4
Answer: d
<?php
?>
a) 106
b) 103
c) 104
d) 209
Answer: c
<?php
echo(atan(0.50));
?>
a) 0.11845976421345
b) 0.23568451142521
c) 0.46364760900081
d) 1
Answer: c
<?php
?>
b) GREETING
Answer: a
<?php
echo defined("GREETING");
?>
a) 1
b) 0
c) 3
d) 4
Answer: b
<?php
echo "chr($total)";
$var1 = "sum";
$var1(5, 44);
?>
a) Error
b) 49
c) 1
d) Sum
Answer: c
<?php
echo "cos($total)";
sum(5,-5);
?>
a) 0
b) 1
c) 0.5
d) -0.5
Answer: b
<?php
function b()
function a()
b();
b();
a();
?>
b) b is executeda is executed
c) a is executed
Answer: d
<?php
$z = $x + $y;
return $z;
?>
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
<?php
function addFive($num)
$num += 5;
function addSix(&$num)
{
$num += 6;
$orignum = 10;
addFive( &$orignum );
addSix( $orignum );
?>
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
Answer: b
<?php
?>
b) Error
Answer: c
<?php
function sayHello()
$function_holder = "sayHello";
$function_holder();
?>
a) No Output
b) Error
c) sayHello
d) HelloWorld
Answer: d
<?php
function one()
function two()
one();
two();
?>
a) error
b) this works
Answer: c
<?php
function do($myString)
?>
a) 4
b) 5
c) 2
d) None of the mentioned
Answer: a
<?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
<?php
echo ucwords($title);
?>
Answer: d
744. What will be the output of the following PHP code?
<?php
?>
a) SaladSaladSaladSaladSalad is good
b) is good SaladSaladSaladSaladSalad
c) is good Salad
d) Salad is good
Answer: d
<?php
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
?>
a) I love my country
b) i love my Country
c) I love my Country
d) I Love My Country
Answer: d
<?php
?>
a) welcome to India
b) welcome to india
c) Welcome to India
d) Welcome to india
Answer: a
<?php
echo hex2bin("48656c6c6f20576f726c6421");
?>
a) Hello World!
b) welcome to india
c) This is PHP!
d) MCQ questons
Answer: a
<?php
echo($str);
?>
Answer: c
<?php
?>
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. )
d) Array ( [1] => Hello [2] => world. [3+ => It’s *4+ => a *5+ => beautiful *6+ => day. )
Answer: b
<?php
a) Hilla Warld
b) Hello World
c) ia
d) eo
Answer: b
<?php
?>
a) 3
b) 7
c) 8
d) 10
Answer: b
<?php
function A1($x)
switch($x)
case 1:
break;
case 2:
//this statement is the same as if($x == 2)
break;
case 3:
break;
case 4:
break;
default:
//this statement is the same as if $x does not equal the other conditions
break;
A1(9);
?>
Answer: d
<?php
function uppercase($string)
echo ucwords($string);
$wow = "uppercase";
?>
c) Uppercase
Answer: d
<?php
function TV($string)
function b()
b();
?>
b) Error
Answer: b
<?php
function TV($string)
function b()
function b()
b();
?>
b) Error
Answer: a
<?php
function TV($string)
{
function b()
function b()
b();
TV("Sherlock");
?>
b) Error
Answer: b
<?php
function TV($string)
function b()
a("Sherlock");
b();
?>
b) Error
Answer: c
<?php
echo $result;
?>
a) Error
b) 0
c) 42
d) 84
Answer: a
<?php
function calc($num1, $num2)
return $total;
echo $result;
?>
a) Error
b) 0
c) 42
d) 84
Answer: b
<?php
$var = 10;
function one()
echo $var;
one();
?>
a) Error
b) 10
c) No Output
Answer: c
762. What will be the output of the following PHP code?
<?php
function mine($m)
if ($m < 0)
if ($ >= 0)
mine(0);
?>
a) Less Than 0
b) Not True
c) No Output
Answer: b
<?php
$x = 75;
$y = 25;
function addition()
addition();
echo $z;
?>
a) 100
b) error
c) 75
d) 25
Answer: a
<?php
function 2myfunc()
2myfunc();
?>
a) Hello World
b) No Output
c) ERROR
Answer: c
<?php
function _func()
_func();
?>
a) Hello World
b) No Output
c) ERROR
Answer: a
<?php
function test($int)
if ($int == 1)
if ($int == 2)
test(1);
TEST(2);
?>
a) This Works
d) ERROR
Answer: c
<?php
function mine($num)
$num = 2 + $num;
echo $num;
}
mine(3);
?>
a) 3
b) $num
c) 5
Answer: c
<?php
function mine($num)
$num = 2 + $num;
echo "$num";
mine(3);
?>
a) 3
b) $num
c) 5
Answer: b
<?php
function one($string)
{
echo "I am ". $String;
one("Batman");
?>
a)
am Batman
b) I am
c) Batman
d) ERROR
Answer: d
<?php
function string($title);
$title = ucwords($title);
echo lcfirst($title);
?>
Answer: d
function multi($num)
if ($num == 3)
if ($num == 7)
if ($num == 8)
if ($num == 19)
multi($can);
?>
a) I Wonder
b) Which One
c) Is The
d) Correct Answer
Answer: b
<?php
function movie($int)
movie(0);
?>
Answer: a
<?php
function colour()
colour();
?>
a)
red
green
blue
yellow
b)
green
blue
yellow
red
c)
red
blue
yellow
green
d)
red
green
yellow
blue
Answer: a
<?php
return $sum;
b) Error
Answer: c
<?php
function time($string)
time("ims");
?>
a) Time Pa55
b) Towe Pa55
c) Towe Pass
d) Time Pass
Answer: d
<?php
function constant()
echo greeting;
}
?>
a) Welcome to Narnia
b) greeting
c) GREETING
d) ERROR
Answer: d
<?php
function constant()
echo greeting;
?>
a) Welcome to Narnia
b) greeting
c) GREETING
d) ERROR
Answer: a
<?php
function start($string)
return 20;
else
return 40;
$t = start(90);
else
?>
c) ERROR
Answer: b
<?php
function case()
case();
?>
a) Hello World!
b)
Hello World!
Hello World!
c)
Hello World!
Hello World!
Hello World!
Answer: c
<?php
function email()
$email = ’user@yahoo.com’;
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()
string();
?>
a) o world!
b) Hello world!
c) 111
d) No Output
Answer: a
<?php
function CalAll($x,$y)
echo "<br>";
echo "<br>";
echo "<br>";
echo "<br>";
$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