0% found this document useful (0 votes)
13 views

PHP Q B(2)

The document consists of a series of multiple-choice questions related to PHP programming, covering topics such as PHP syntax, functions, object-oriented programming, error handling, and file operations. Each question provides four answer options, testing knowledge on various aspects of PHP. The questions range from basic to advanced concepts, making it suitable for individuals preparing for a PHP-related examination or assessment.

Uploaded by

beluga.9893
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

PHP Q B(2)

The document consists of a series of multiple-choice questions related to PHP programming, covering topics such as PHP syntax, functions, object-oriented programming, error handling, and file operations. Each question provides four answer options, testing knowledge on various aspects of PHP. The questions range from basic to advanced concepts, making it suitable for individuals preparing for a PHP-related examination or assessment.

Uploaded by

beluga.9893
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

1. Who is the father of PHP?

a) Rasmus Lerdorf
b) Willam Makepiece
c) Drek Kolkevi
d) List Barely
2. PHP files have a default file extension of..
a) .html
b) .xml
c) .php
d) .ph
3. A PHP script should start with ___ and end with ___:
a) < php >
b) < ? php ?>
c) <? ?>
d) <?php ?>
4. Which version of PHP introduced Try/catch Exception?
a)PHP 4
b)PHP 5
c)PHP 5.3
d)PHP 6
5. Which of the below symbols is a newline character?
a) \r
b) \n
c) /n
d) /r
6. If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?
a) 12
b) 1
c) Error
d) 5
7. 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
8. Which statement will output $x on the screen?
a) echo “\$x”;
b) echo “$$x”;
c) echo “/$x”;
d) echo “$x;”;
9. Which one of the following is the right way of defining a function in PHP?
a) function { function body }
b) data type functionName(parameters) { function body }
c) functionName(parameters) { function body }
d) function fumctionName(parameters) { function body }
10. A function in PHP which starts with __ (double underscore) is know as..
a) Magic Function
b) Inbuilt Function
c) Default Function
d) User Defined Function
11. Which one of the following PHP functions can be used to build a function that accepts any
number of arguments?
a) func_get_argv()
b) func_get_argc()
c) get_argv()
d) get_argc()
12. Which one of the following PHP functions can be used to find files?
a) glob()
b) file()
c) fold()
d) get_file()
13. Which of the following PHP functions can be used to get the current memory usage?
a) get_usage()
b) get_peak_usage()
c) get_memory_usage()
d) get_memory_peak_usage()
14. Which of the following PHP functions can be used for generating unique id’s?
a) uniqueid()
b) id()
c) md5()
d) mdid()
15. Which one of the following functions can be used to compress a string?
a) zip_compress()
b) zip()
c) compress()
d) gzcompress()
16. PHP’s numerically indexed array begin with position __.
a) 1
b) 2
c) 0
d) -1
17. Which function will return true if a variable is an array or false if it is not?
a) this_array()
b) is_array()
c) do_array()
d) in_array()
18. 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()
19. Which function can be used to move the pointer to the previous array position?
a) last()
b) before()
c) prev()
d) previous()
20. Which function returns an array consisting of associative key/value pairs?
a) count()
b) array_count()
c) array_count_values()
d) count_values()
21. Which of the functions is used to sort an array in descending order?
a) sort()
b) asort()
c) rsort()
d) dsort()
22. Say in the above question you need to get the array sorted in the manner we humans would
have done it i.e picture1 then picture2 etc.. Which of the following function should be used?
a) dsort()
b) casesort()
c) natcasesort()
d) naturalsort()
23. 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
24. 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
25. 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
26. Which one of the following property scopes is not supported by PHP?
a) friendly
b) final
c) public
d) static
27. 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 ();
28. 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’;
29. 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;
30. 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();
31. Which method scope prevents a method from being overridden by a subclass?
a) Abstract
b) Protected
c) Final
d) Static
32. PHP recognizes constructors by the name..
a) classname()
b) _construct()
c) function _construct()
d) function __construct()
33. Which version of PHP introduced the instanceof keyword?
a) PHP 4
b) PHP 5
c) PHP 5.3
d) PHP 6
34. Which one of the following functions is used to determine whether a class exists?
a) exist()
b) exist_class()
c) class_exist()
d) __exist()
35. Which one of the following functions is used to determine object type?
a) obj_type()
b) type()
c) is_a()
d) is_obj()
36. Which one of the following keyword is used to inherit our subclass into a superclass?
a) extends
b) implements
c) inherit
d) include
37. Which keyword is used to refer to properties or methods within the class itself?
a) private
b) public
c) protected
d) $this
38. 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
39. Which version of PHP introduced the advanced concepts of OOP?
a) PHP 4
b) PHP 5
c) PHP 5.3
d) PHP 6
40. 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);
41. 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
42. 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
43. Which method is used to tweak an object’s cloning behavior?
a) clone()
b) __clone()
c) _clone
d) object_clone()
44. 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
45. Which magic method is used to implement overloading in PHP?
a) __call
b) __invoke
c) __wakeup
d) __unset
46. How many error levels are available in PHP?
a) 14
b) 15
c) 16
d) 17
47. 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
48. Which version of PHP introduced E_STRICT Error level?
a) PHP 4
b) PHP 5
c) PHP 5.2
d) PHP 5.3
49. Which character do the error_reporting directive use to represent the logical operator NOT?
a) /
b) !
c) ~
d) ^
50. 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
51. 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
52. Which of the following is/are a PHP code editor?
i) Notepad
ii) Notepad++
iii) Adobe Dreamweaver
iv) PDT
a) Only iv)
b) All of the mentioned.
c) i), ii) and iii)
d) Only iii)
53. Which of the following must be installed on your computer so as to run PHP script?
i) Adobe Dreamweaver
ii) PHP
iii) Apache
iv) IIS
a) All of the mentioned.
b) Only ii)
c) ii) and iii)
d) ii), iii) and iv)

54. What function computes the difference of arrays?

A) array_diff
B) diff_array
C) arrays_diff
D) diff_arrays

55. There are three different kind of arrays:

A) Numeric array, String array, Multidimensional array


B) Numeric array, Associative array, Dimensional array

C) Numeric array, Associative array, Multidimensional array

D) Const array, Associative array, Multidimensional array

56. Which array function checks if the specified key exists in the array
(A) => array_key_exist()
(B) => array_key_exists()
(C) => array_keys_exists()
57. 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()
58. 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
59. Which function is responsible for sending a custom message to the system log?
a) systemlog()
b) syslog()
c) log_system()
d) sys_log()

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


a) 3
b) 2
c) 4
d) None

61. 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

62. Which one of the following does not describe a validating filter?
a) Are used to allow or disallow specified 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
63. Which one of the following filter checks if variable of specified type exists?
a) filter_has_var
b) filter_var
c) filter_id
d) filter_var_array

64. Which one of the following regular expression matches any string containing zero or one p?
a) p+
b) p*
c) P?
d) p#

65. [:alpha:] can also be specified as..


a) [A-Za-z0-9]
b) [A-za-z]
c) [A-z]
d) [a-z]

66. How many functions does PHP offer for searching strings using POSIX style regular
expression?
a) 7
b) 8
c) 9
d) 10

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


a) PHP 4
b) PHP 5
c) PHP 5.2
d) PHP 5.3

68. 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

69. The filesize() function returns the file size in ___.


a) bits
b) bytes
c) kilobytes
d) gigabytes
70. 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()

71. 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()

72. 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()

73. Which one of the following function is capable of reading a specific number of characters
form a file?
a) fgets()
b) fget()
c) fileget()
d) filegets()

74. 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()

75. 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()

76. Which one of the following functions is used to search a string?

A) preg_match

B) preg_search

C) preg_find
D) preg_found

77. 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()

78. 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()

79. 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

80. Which one of the following databases has PHP supported almost since the beginning?
a) Oracle Database
b) SQL
c) SQL+
d) MySQL

81. The updated MySQL extension released with PHP 5 is typically referred to as..
a) MySQL
b) mysql
c) mysqli
d) mysqly

82. 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

83. I n 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
84. 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);

85. 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()

86. 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’);

87. 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()

88. Which method returns the error code generated from the execution of the last MySQL function?
a) errno()
b) errnumber()
c) errorno()
d) errornumber()

89. If there is no error, then what will the error() method return?
a) TRUE
b) FALSE
c) Empty String
d) 0

90. Which one of the following statements should be used to include a file?
a) #include ‘filename’;
b) include ‘filename’;
c) @include ‘filename’;
d) #include ;
91. Which one of the following methods is responsible for sending the query to the database?
a) query()
b) send_query()
c) sendquery()
d) query_send()

92. Which one of the following methods recuperates any memory consumed by a result set?
a) destroy()
b) remover()
c) alloc()
d) free()

93. 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) fetch_array() and fetch_column()

94. 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) new_rows()

95. Which version of MySQL introduced the prepared statements?


a) MySQL 4.0
b) MySQL 4.1
c) MySQL 4.2
d) MySQL 4.3

96. 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()

97. Which one of the following methods is used to recuperating prepared statements resources?
a) end()
b) finish()
c) final()
d) close()
98. 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) row()

99. Which method rolls back the present transaction?


a) commit()
b) undo()
c) back()
d) rollback()

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


a) ShopProduct
b) Shopproduct
c) Shopproduct1
d) 1shopproduct

101. Fill in the blank with the best option. An Object is a/an ___ of a class.
a) type
b) prototype
c) instance
d) object

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


a) ::
b) =
c) ->
d) .

103. 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

104. Which keyword precedes a method name?


a) method
b) function
c) public
d) protected
105. 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

106. 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

107. 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

108. The URLs in the administrative links won’t mean anything to admin.php unless you modify ___.
a) .htaccess
b) .adminaccess
c) .htmlaccess
d) .urlaccess

109. The (|/) tells the server to match ___.


a) nothing
b) forward slash
c) backward slash
d) either nothing or a forward slash

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


a) inherited class
b) abstract class
c) constant class
d) every class

111. . Which one of the following keywords is used to define an abstract class?
a) extends
b) implements
c) abstract
d) new
112. 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();

113. . Atleast how many abstract methods must an abstract class contain?
a) None
b) One
c) Two
d) Five

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


a) interface
b) get
c) inherit
d) implements

115. 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()

116. Which one of the following keyword is used in conjunction with an Exception object?
a) throws
b) exception
c) throw
d) final

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


a) stop
b) end
c) break
d) final

118. 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
119. 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()

120. 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()

121. . Which method introduced in PHP 5, is invoked just before an object is garbage collected?
a) __collect()
b) __garbage()
c) __destruct()
d) __destructor()

122. 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

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


a) original
b) pseudo
c) external
d) copied

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


a) __get()
b) __isset()
c) __unset()
d) __undefined()

125. 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
126. 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

127. What is the default value of max_input_time directive?


a) 30 seconds
b) 60 seconds
c) 120 seconds
d) 1 second

128. 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

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


a) 2
b) 3
c) 4
d) 5

130. 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”)

131. Which of the following is not true?

a) PHP can be used to develop web applications.

b) PHP makes a website dynamic

c) PHP applications can not be compile

d) PHP can not be embedded into html

132. PHP scripts are enclosed within _______


A. <php> . . . </php>
B. <?php . . . ?>
C. ?php . . . ?php
D. <p> . . . </p>
133.
Which of the following variables is not a predefined variable?

a. $get
b. $ask
c. $request
d. $post

134. When you need to obtain the ASCII value of a character which of the following
function you apply in PHP?

a. chr( );
b. asc( );
c. ord( );
d. val( );

135. Which of the following method sends input to a script via a URL?

a. Get
b. Post
c. Both
d. None

136. Which of the following function returns a text in title case from a variable?

A. ucwords($var)
B. upper($var)

C. toupper($var)
D. ucword($var)

137. Which of the following function returns the number of characters in a string
variable?

a. count($variable)
b. len($variable)
c. strcount($variable)
d. strlen($variable)

138. PHP files have a default file extension of..


a) .html
b) .xml
c) .php
d) .ph

139. 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) All of the mentioned
d) None of the mentioned

140. We can use ___ to comment a single line?


i) /?
ii) //
iii) #
iv) /* */
a) Only ii)
b) i), iii) and iv)
c) ii), iii) and iv)
d) Both ii) and iv)

141. 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) All of the mentioned.
c) Only iii)
d) Only i)

142. Which of following variables can be assigned a value to it?


i) $3hello
ii) $_hello
iii) $this
iv) $This
a) All of the mentioned
b) Only ii)
c) ii), iii) and iv)
d) ii) and iv)

143. Which of the following PHP statements will output Hello World on the screen?
i) echo (“Hello World”);
ii) print (“Hello World”);
iii) printf (“Hello World”);
iv) sprintf (“Hello World”);
a) i) and ii)
b) i), ii) and iii)
c) All of the mentioned
d) i), ii) and iv)

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

1. <?php
2. $a = "clue";
3. $a .= "get";
4. echo "$a";
5. ?>

a) get
b) true
c) false
d) clueget

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

1. <?php
2. $num = 10;
3. echo 'What is her age? \n She is $num years old';
4. ?>

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

146. 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) and iii)
b) All of the mentioned
c) None of the mentioned
d) ii), iii) and iv)

147. 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) All of the mentioned
b) None of the mentioned
c) i) and ii)
d) iii) and iv)

148. 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)

149. . 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

150. 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

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


a) __call
b) __invoke
c) __wakeup
d) __unset

152. . Which one of the following PHP functions can be used to find files?
a) glob()
b) file()
c) fold()
d) get_file()

153. Which function sets the file filename’s last-modified and last-accessed times?
a) sets()
b) set()
c) touch()
d) touched()

154. Which function is useful when you want to output the executed command’s result?
a) out_cmm()
b) out_system()
c) cmm()
d) system()

155. Which one of the following function reads a directory into an Array?
a) scandir()
b) readdir()
c) scandirectory()
d) readdirectory()

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

1. <?php
2. echo "chr(52)";
3. ?>

a) 1
b) 2
c) 3
d) 4

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

1. <?php
2. echo ord ("hi");
3. ?>

a) 106
b) 103
c) 104
d) 209

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


1. <?php
2. echo ucwords("i love my country");
3. ?>

a) I love my country
b) i love my Country
c) I love my Country
d) I Love My Country

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

1. <?php
2. echo lcfirst("welcome to India");
3. ?>

a) welcome to India
b) welcome to india
c) Welcome to India
d) Welcome to india

160. Which of the following are valid function names?


i) function()
ii) €()
iii) .function()
iv) $function()
a) Only ii)
b) None of the mentioned.
c) All of the mentioned.
d) iii) and iv)

161. How many functions does PHP offer for searching and modifying strings using Perl-
compatible regular expressions.
a) 7
b) 8
c) 9
d) 10

162. 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) None of the mentioned
d) All of the mentioned
163. Which one of the following functions will convert a string to all uppercase?
a) strtoupper()
b) uppercase()
c) str_uppercase()
d) struppercase()

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

1. <?php
2. echo str_pad("Salad", 5)." is good.";
3. ?>

a) SaladSaladSaladSaladSalad is good
b) is good SaladSaladSaladSaladSalad
c) is good Salad
d) Salad is good

165. 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()

166. 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()

167. 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)

168. Which one of the following regular expression matches any string containing zero or one p?
a) p+
b) p*
c) P?
d) p#
169. How many functions does PHP offer for searching strings using POSIX style regular
expression?
a) 7
b) 8
c) 9
d) 10

170. . 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)

171. Which function will return true if a variable is an array or false if it is not?
a) this_array()
b) is_array()
c) do_array()
d) in_array()

172. Which two predefined variables are used to retrieve information from forms?
a) $GET & $SET
b) $_GET & $_SET
c) $__GET & $__SET
d) GET & SET

173. 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

174. When you use the $_GET variable to collect data, the data is visible to..
a) none
b) only you
c) everyone
d) selected few

175. Which variable is used to collect form data sent with both the GET and POST methods?
a)$BOTH
b)$_BOTH
c)$REQUEST
d)$_REQUEST

176. Which one of the following should not be used while sending passwords or other sensitive
information?
a) GET
b) POST
c) REQUEST
d) NEXT

177. 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()

178. To validate an e-mail 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

179. How many validation filters like FILTER_VALIDATE_EMAIL are currently available?
a) 5
b) 6
c) 7
d) 8

180. In mail($param2, $param2, $param3, $param4), the $param2 contains:

a. The message
b. The recipient
c. The header
d. The subject

181. mysql_connect( ) does not take following parameter

a. database host
b. user ID
c. password
d. database name

182. Which of the following is not a session function?

a. sssion_decode
b. session_destroy
c. session_id
d. session_pw

183. When uploading a file if the UPLOAD_ERR-OK contains value 0 it means

a. Uplaod is not successful, error occurred


b. The file uploaded with success
c. Uploaded file size is 0
d. File upload progress is 0% completed

184. Which of the following statement produce different output

a. <?echo "This is php example"; ?>


b. <P="This is php example"; ?>
c. <?PHP echo "This is php example"; php?>
d. <script language="php"> print "This is php example";</script>

185. Which of the following delimiter is ASP style?

a. </ />
b. <% %>
c. <? ?>
d. <script language="php"> </script>

186. Php supports all four different ways of delimiting. In this context identify the false
statement

a. You can use any of the delimiting style


b. You can use different delimiting styles in same page
c. You can use any delimiting style but must use a single style consistently for a page
d. Variables declared in previous blocks are remenbered on later blocks too!

187. Which of following commenting is supported by Php

a. Single line c++ syntax - //


b. Shell syntax - #
c. Both of above
d. None of above

188. Which of following function return 1 when output is successful?

a. echo ( )
b. print ( )
c. both
d. None

189. Which of the following type specifier is invalid in print f ( ) functions


a. %a
b. %b
c. %c
d. %d

190. Which of the following function can assign the output to a string variable

a. echo ( )
b. print ( )
c. print f ( )
d. s print f ( )

191. Which of the following data type is not seal or datetype supported by PHP

a. Array
b. String
c. Float
d. Boolean

192. If a boolean variable $ alive= 5;

a. $ alive is false
b. $ alive is true
c. $ alive is overflow
d. the statement is snot valid

193. For integer data type PHP 6 introduced

a. 8 bit integer value


b. 16 bit integer value
c. 32 bit integer value
d. 64 bit integer value

You might also like