PHP Interview Questions Level-1

1. What is PHP?
2. What do the initials of PHP stand for?
3. Which programming language does PHP resemble?
4. What does PEAR stand for?
5. What is the main difference between PHP 4 and PHP 5?
6. Is multiple inheritance supported in PHP?
7. What is the meaning of a final class and a final method?
8. How is the comparison of objects done in PHP?
9. How can PHP and HTML interact?
10. What type of operation is needed when passing values through a form or an URL?
11. How can PHP and Javascript interact?
12. What is needed to be able to use image function?
13. What is the use of the function 'imagetypes()'?
14. What are the functions to be used to get the image's properties (size, width, and height)?
15. How failures in execution are handled with include() and require() functions?
16. What is the main difference between require() and require_once()?
17. How can I display text with a PHP script?
18. How can we display information of a variable and readable by a human with PHP?
19. How is it possible to set an infinite execution time for PHP script?
20. What does the PHP error 'Parse error in PHP - unexpected T_variable at line x' means?
21. What should we do to be able to export data into an Excel file?
22. What is the function file_get_contents() useful for?
23. How can we connect to a MySQL database from a PHP script?
24. What is the function mysql_pconnect() useful for?
25. How be the result set of Mysql handled in PHP?

PHP Interview Questions Level-2

26. How is it possible to know the number of rows returned in the result set?
27. Which function gives us the number of affected entries by a query?
28. What is the difference between mysqli_fetch_object() and mysqli_fetch_array()?
29. How can we access the data sent through the URL with the GET method?
30. What is the actually used PHP version?
31. How do you execute a PHP script from the command line?
32. How to run the interactive PHP shell from the command line interface?
33. What is the correct and the most two common way to start and finish a PHP block of code?
34. How can we display the output directly to the browser?
35. How can we access the data sent through the URL with the POST method?
36. How can we check the value of a given variable is a number?
37. How can we check the value of a given variable is alphanumeric?
38. How do I check if a given variable is empty?
39. What does the unlink() function mean?
40. What does the unset() function mean?
41. How do I escape data before storing it in the database?
42. How is it possible to remove escape characters from a string?
43. How can we automatically escape incoming data?
44. What does the function get_magic_quotes_gpc() means?
45. Is it possible to remove the HTML tags from data?
46. what is the static variable in function useful for?
47. How can we define a variable accessible in functions of a PHP script?
48. How is it possible to return a value from a function?
49. What does the function get_magic_quotes_gpc() means?
50. Is it possible to remove the HTML tags from data?

PHP Interview Questions Level-3

51. what is the static variable in function useful for?
52. What is the most convenient hashing method to be used to hash passwords?
53. Which cryptographic extension provide generation and verification of digital signatures?
54. How is a constant defined in a PHP script?
55. How can you pass a variable by reference?
56. Will a comparison of an integer 12 and a string "13" work in PHP?
57. How is it possible to cast types in PHP?
58. When is a conditional statement ended with endif?
59. How is a constant defined in a PHP script?
60. How can you pass a variable by reference?
61. How is the ternary conditional operator used in PHP?
62. What is the function func_num_args() used for?
63. What does accessing a class via :: means?
64. In PHP, objects are they passed by value or by reference?
65. Are Parent constructors called implicitly inside a class constructor?
66. What's the difference between __sleep and __wakeup?
67. What is faster?
68. what is the definition of a session?
69. How to initiate a session in PHP?
70. How can you propagate a session id?
71. What is the meaning of a Persistent Cookie?
72. When do sessions end?
73. What is the difference between session_unregister() and session_unset()?
74. What does $GLOBALS mean?
75. What does $_SERVER mean?

PHP Interview Questions Level-4

76. What does $_FILES means?
77. What is the difference between $_FILES['userfile']['name'] and $_FILES['userfile']['tmp_name']?
78. How can we get the error when there is a problem to upload a file?
79. How can we change the maximum size of the files to be uploaded?
80. What does $_ENV mean?
81. What does $_COOKIE mean?
82. What does the scope of variables mean?
83. What does $GLOBALS mean?
84. What does $_SERVER mean?
85. What does $_FILES means?
86. what the difference between the 'BITWISE AND' operator and the 'LOGICAL AND' operator?
87. What are the two main string operators?
88. What does the array operator '===' means?
89. What is the differences between $a != $b and $a !== $b?
90. How can we determine whether a PHP variable is an instantiated object of a certain class?
91. What is the goto statement useful for?
92. what is the difference between Exception::getMessage and Exception:: getLine?
93. What does the expression Exception::__toString means?
94. How is it possible to parse a configuration file?
95. How can we determine whether a variable is set?
96. What is the difference between the functions strstr() and stristr()?
97. what is the difference between for and foreach?
98. Is it possible to submit a form with a dedicated button?
99. What is the difference between ereg_replace() and eregi_replace()?
100. Is it possible to protect special characters in a query string?

PHP Interview Questions Level-5

101. what is the difference between for and foreach?
102. Is it possible to submit a form with a dedicated button?
103. What is the difference between ereg_replace() and eregi_replace()?
104. Is it possible to protect special characters in a query string?
105. What are the three classes of errors that can occur in PHP?
106. What is the difference between characters \034 and \x34?
107. How can we pass the variable through the navigation between the pages?
108. Is it possible to extend the execution time of a PHP script?
109. Is it possible to destroy a cookie?
110. is the default session time in PHP?
111. Is it possible to use COM component in PHP?
112. Explain whether it is possible to share a single instance of a Memcache between multiple PHP projects?
113. Explain how you can update Memcached when you make changes to PHP?
114. What is the use of "echo" in php?
115. How to include a file to a php page?
116. What's the difference between include and require?
117. require_once(), require(), include().What is difference between them?
118. Differences between GET and POST methods ?
119. What is the difference between Session and Cookie?
120. How to set cookies in PHP?
121. How to Retrieve a Cookie Value?
122. How to create a session? How to set a value in session ? How to Remove data from a session?
123. what types of loops exist in php?
124. What is the use of explode() function ?
125. What is the difference between explode() and str_split() functions?

PHP Interview Questions Level-6

126. What is the use of mysql_real_escape_string() function?
127. How to strip whitespace (or other characters) from the beginning and end of a string ?
128. What is the use of header() function in php ?
129. How to redirect a page in php?
130. How stop the execution of a php scrip ?
131. How to set a page as a home page in a php based site ?
132. How to find the length of a string?
133. what is the use of rand() in php?
134. what is the use of isset() in php?
135. What is the difference between mysql_fetch_array() and mysql_fetch_assoc() ?
136. What is mean by an associative array?
137. What is the importance of "method" attribute in a html form?
138. What is the importance of "action" attribute in a html form?
139. What is the use of "enctype" attribute in a html form?
140. How to create an array of a group of items inside an HTML form ?
141. Define Object-Oriented Methodology
142. How do you define a constant?
143. How send email using php?
144. How to find current date and time?
145. Difference between mysql_connect and mysql_pconnect?
146. What is the use of "ksort" in php?
147. What is the difference between $var and $$var?
148. What are the encryption techniques in PHP
149. What is the use of the function htmlentities?
150. How to delete a file from the system

PHP Interview Questions Level-7

151. How to get the value of current session id?
152. What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?
153. What are the different types of errors in PHP ?
154. what is sql injection ?
155. What is x+ mode in fopen() used for?
156. How to find the position of the first occurrence of a substring in a string
157. What is PEAR?
158. Distinguish between urlencode and urldecode?
159. What are the different errors in PHP?
160. What are the common usage of PHP?
161. In how many ways you can embed PHP code in an HTML page?
162. What is the purpose of php.ini file?
163. What is escaping to PHP?
164. What do you mean by having PHP as whitespace insensitive?
165. Is PHP a case sensitive language?
166. What are the characteristics of PHP variables?
167. What are the different types of PHP variables?
168. What are rules for naming a PHP variable?
169. What are the rules for determine the "truth" of any value not already of the Boolean type?
170. What is NULL?
171. How will you define a constant in PHP?
172. What is the purpose of constant() function?
173. What are the differences between PHP constants and variables?
174. What are PHP magic constants?
175. What is the purpose of _LINE_ constant?

PHP Interview Questions Level-8

176. What is the purpose of _FILE_ constant?
177. What is the purpose of _FUNCTION_ constant?
178. What is the purpose of _CLASS_ constant?
179. What is the purpose of _METHOD_ constant?
180. What is the purpose of break statement?
181. What is the purpose of continue statement?
182. Explain the syntax for 'foreach' loop.
183. What is numeric array?
184. What is associate array?
185. What is Multidimensional array?
186. How will you concatenate two strings in PHP?
187. How will you find the length of a string in PHP?
188. How will you locate a string within a string in PHP?
189. How will you get environment variables in PHP?
190. How will you get the browser's details using PHP?
191. How will you generate random numbers using PHP?
192. What is the purpse $_PHP_SELF variable?
193. How will you redirect a page using PHP?
194. How can you display a file download dialog box using PHP?
195. How will you get information sent via get method in PHP?
196. How will you get information sent via post method in PHP?
197. What is the purpse $_REQUEST variable?
198. Which function will you use to create an array?
199. How can you sort an array?
200. What is the use of 'print' in php?

PHP Interview Questions Level-9

201. What is use of in_array() function in php ?
202. What is use of count() function in php ?
203. What is the difference between single quoted string and double quoted string?
204. How will you concatenate two strings?
205. What is the use of $_REQUEST variable?
206. How will you include the content of a PHP file into another PHP file?
207. What is the difference between include() Function and require() Function?
208. Can you assign the default values to a function parameters?
209. How will you set cookies using PHP?
210. How will you get cookies using PHP?
211. How will you make a check that a cookie is set or not?
212. How will you delete a cookie?
213. How will you start a session in PHP?
214. How will you access session variables in PHP?
215. How will you check if session variable is already set or not in PHP?
216. How will you unset a single session variable?
217. How will you destroy the session?
218. How will you send an email using PHP?
219. What is the purpose of $_FILES variable in PHP?
220. How will you access the uploaded file in PHP?
221. How will you access the actual name of the uploaded file in PHP?
222. How will you access the size of the uploaded file in PHP?
223. How will you access the content type of the uploaded file in PHP?
224. How will you access the error code associated with file upload in PHP?
225. What is the purpose of $GLOBALS variable in PHP?

PHP Interview Questions Level-10

226. What is the purpose of $_SERVER variable in PHP?
227. What is the purpose of $_COOKIE variable in PHP?
228. What is the purpose of $_SESSION variable in PHP?
229. What is the purpose of $_PHP_SELF variable in PHP?
230. What is the purpose of $php_errormsg variable in PHP?
231. How ereg() function works?
232. How eregi() function works?
233. How split() function works?
234. How preg_match() function works?
235. How preg_split() function works?
236. How will you retrieve the error message using Exception class in PHP when error occured?
237. How will you retrieve code of exception using Exception class in PHP when error occured?
238. How will you retrieve source filename using Exception class in PHP when error occured?
239. How will you retrieve source line using Exception class in PHP when error occured?
240. How will you retrieve stack trace using Exception class in PHP when error occured?
241. How will you retrieve formated string of trace in PHP when error occured?
242. How will you get the current date and time using PHP?
243. What is the purpose of getdate() function?
244. What is the purpose of date() function?
245. How will you connect a MySql database using PHP?
246. How will you create a MySql database using PHP?
247. How will you close a MySql database using PHP?
248. How will you parse an XML document using PHP?
249. Can you create a class in PHP?
250. How will you open a file in readonly mode?

PHP Interview Questions Level-11

251. How will you read a file in php?
252. How will you get the size of a file in php?
253. How will you check if a file exists or not using php?
254. How will you add a constructor function to a PHP class?
255. How will you add a destructor function to a PHP class?
256. How will you access the reference to same object within the object in PHP?
257. How will you create objects in PHP?
258. How will you call member functions of a class in PHP?
259. What is function overriding?
260. What are interfaces in PHP?
261. What is the use of final keyword?
262. What is the use of “echo” in php?
263. What’s the difference between include and require?
264. How to declare an array in php?
265. What is the use of ‘print’ in php?
266. How to create a mysql connection?
267. How to select a database?
268. How to execute an sql query? How to fetch its result ?
269. Write a program using while loop
270. How we can retrieve the data in the result set of MySQL using PHP?
271. What is the use of explode() function ?
272. What is the difference between explode() and split() functions?
273. What is the importance of “method” attribute in a html form?
274. What is the importance of “action” attribute in a html form?
275. What is the use of “enctype” attribute in a html form?

PHP Interview Questions Level-12

276. What is the use of “ksort” in php?
277. What is PEAR in PHP?
278. Who is known as the father of PHP?
279. What was the old name of PHP?
280. Explain the difference b/w static and dynamic websites?
281. What is the name of scripting engine in PHP?
282. Explain the difference between PHP4 and PHP5.
283. What are the popular Content Management Systems (CMS) in PHP?
284. What are the popular frameworks in PHP?
285. Which programming language does PHP resemble to?
286. List some of the features of PHP7.
287. What is "echo" in PHP?
288. What is "print" in PHP?
289. What is the difference between "echo" and "print" in PHP?
290. How a variable is declared in PHP?
291. What is the difference between $message and $$message?
292. What are the ways to define a constant in PHP?
293. What are magic constants in PHP?
294. How many data types are there in PHP?
295. How to do single and multi line comment in PHP?
296. What are the different loops in PHP?
297. What is the use of count() function in PHP?
298. What is the use of header() function in PHP?
299. What does isset() function?
300. Explain PHP parameterized functions.

PHP Interview Questions Level-13

301. Explain PHP variable length argument function
302. Explain PHP variable length argument function.
303. What is the array in PHP?
304. How many types of array are there in PHP?
305. Explain some of the PHP array functions?
306. What is the difference between indexed and associative array?
307. How to get the length of string?
308. Explain some of the PHP string functions?
309. What are the methods to submit form in PHP?
310. How can you submit a form without a submit button?
311. What are the ways to include file in PHP?
312. Differentiate between require and include?
313. Explain setcookie() function in PHP?
314. How can you retrieve a cookie value?
315. What is a session?
316. What is the method to register a variable into a session?
317. What is $_SESSION in PHP?
318. What is PHP session_start() and session_destroy() function?
319. Write syntax to open a file in PHP?
320. How to read a file in PHP?
321. How to write in a file in PHP?
322. How to delete file in PHP?
323. What is the method to execute a PHP script from the command line?
324. How to upload file in PHP?
325. How to download file in PHP?
326. How can you send email in PHP?
327. How do you connect MySQL database with PHP?
328. How to create connection in PHP?
329. How to create database connection and query in PHP?
330. How can we increase execution time of a PHP script?
331. What are the different types of errors in PHP?
332. How to stop the execution of PHP script?
333. What are the encryption functions in PHP?
334. What is htaccess in PHP?
335. Explain PHP explode() function.
336. Explain PHP split() function.
337. How can we get IP address of a client in PHP?