Olete.in
Articles
Mock Tests
🧪 PHP MCQ Quiz Hub
PHP Mcq Set 2
Choose a topic to test your knowledge and improve your PHP skills
1. How many functions does PHP offer for searching and modifying strings using Perl-compatible regular expressions.
7
8
9
10
2. Which one of the following functions will convert a string to all uppercase?
strtoupper()
uppercase()
str_uppercase()
struppercase()
3. Which one of the following functions can be used to concatenate array elements to form a single delimited string?
explode()
implode()
concat()
concatenate()
4. Which one of the following functions finds the last occurrence of a string, returning its numerical position?
strlastpos()
strpos()
strlast()
strrpos()
5. The filesize() function returns the file size in ___________
bits
bytes
kilobytes
gigabytes
6. Which one of the following PHP function is used to determine a file’s last access time?
fileltime()
filectime()
fileatime()
filetime()
7. Which one of the following function is capable of reading a file into an array?
file()
arrfile()
arr_file()
file_arr()
8. Which one of the following function is capable of reading a file into a string variable?
file_contents()
file_get_contents()
file_content()
file_get_content()
9. Which one of the following function is capable of reading a specific number of characters from a file?
fgets()
fget()
fileget()
filegets()
10. Which one of the following function operates similarly to fgets(), except that it also strips any HTML and PHP tags form the input?
fgetsh()
fgetsp()
fgetsa()
fgetss()
11. Which one of the following function outputs the contents of a string variable to the specified resource?
filewrite()
fwrite()
filewrites()
fwrites()
12. Which function sets the file filename last-modified and last-accessed times?
sets()
set()
touch()
touched()
13. Which function is useful when you want to output the executed command result?
out_cmm()
out_system()
cmm()
system()
14. Which one of the following function reads a directory into an Array?
scandir()
readdir()
scandirectory()
readdirectory()
15. The date() function returns ___ representation of the current date and/or time.
Integer
String
Boolean
Float
16. Which one of the following format parameter can be used to identify timezone?
T
N
E
I
17. If the format is F then which one of the following will be returned?
Complete text representation of month
Day of month, with leading zero
Daylight saving time
Day of month, without zeros
18. Which one of the following function is useful for producing a timestamp based on a given date and time?
time()
mktime()
mrtime()
mtime()
19. Which function displays the web page’s most recent modification date?
lastmod()
getlastmod()
last_mod()
get_last_mod()
20. Suppose you want to calculate the date 45 days from the present date which one of the following statement will you use?
totime(“+45”)
totime(“+45 days”)
strtotime(“+45 days”)
strtotime(“-45 days”)
21. To create an object and set the date to JUNE 22, 2013, which one of the following statement should be executed?
$date = Date(“22 JUNE 2013”)
$date = new Date(“JUNE 22 2013”)
$date = DateTime(“22 JUNE 2013”)
$date = new DateTime(“22 JUNE 2013”)
22. How many methods does the DateTime class have?
8
9
10
11
23. How many constants does the DateTime class have?
8
9
10
11
24. Which method is simply an object-oriented version of date()?
DateTime::format()
DateTime::modify()
DateTime::setTime()
DateTime::setDate()
25. Which of the following is the right way to use the DateTime class?
$date = get_Class(DateTime);
$date = class DateTime;
$date = new DateTime();
$date = new class DateTime();
26. Which of the following statements can be used to set the time zone in individual scripts?
date_set_timezone(‘Europe/London’);
date_default_timezone_set(‘Europe/London’);
date_set_default_timezone(‘Europe/London’);
date_default_timezone(‘Europe/London’);
27. Which of the following statements can be used to add two months to the existing date?
$date->modify(‘+2 months’);
$date = modify(‘+2 months’);
$date = modify(‘2+ months’);
$date->modify(‘2+ months’);
28. Which method enables you to calculate whether daylight saving time is in force at a specific date and time?
getOffset()
getTranitions()
ISODate()
savingTime()
29. Which two predefined variables are used to retrieve information from forms?
$GET & $SET
$_GET & $_SET
$__GET & $__SET
GET & SET
30. The attack which involves the insertion of malicious code into a page frequented by other users is known as _____________
basic sql injection
advanced sql injection
cross-site scripting
scripting
31. When you use the $_GET variable to collect data, the data is visible to ______
none
only you
everyone
selected few
32. When you use the $_POST variable to collect data, the data is visible to _____
none
only you
everyone
selected few
33. Which variable is used to collect form data sent with both the GET and POST methods?
$BOTH
$_BOTH
$REQUEST
$_REQUEST
34. Which one of the following should not be used while sending passwords or other sensitive information?
GET
POST
REQUEST
35. Which function is used to remove all HTML tags from a string passed to a form?
remove_tags()
strip_tags()
tags_strip()
36. To validate an email address, which flag is to be passed to the function filter_var()?
FILTER_VALIDATE_EMAIL
FILTER_VALIDATE_MAIL
VALIDATE_EMAIL
VALIDATE_MAIL
37. How many validation filters like FILTER_VALIDATE_EMAIL are currently available?
5
6
7
8
38. How many predefined variables does PHP use to authenticate a user?
1
2
3
4
39. Which function is used to verify whether a variable contains a value?
header()
footer()
inset()
isset()
40. In which authentication method does changing the username or password can be done only by entering the code and making the manual adjustment.
Hard-coding a login pair directly into the script
File-based authentication
Data-based authentication
PEAR’S HTTP authentication
41. The authenticationFile.txt, the file which stores username and password should be stored ___ the server document root.
Inside
Outside
Within
None of the mentioned
42. Which function is used to split a string into a series of substrings, with each string boundary is determined by a specific separator?
break()
divide()
explode()
md5()
43. Which is the most powerful authentication method among the four?
Hard-coding a login pair directly into the script
File-based authentication
Data-based authentication
PEAR’S HTTP authentication
44. Which directive determines whether PHP scripts on the server can accept file uploads?
file_uploads
file_upload
file_input
file_intake
45. 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?
max_take_time
max_intake_time
max_input_time
max_parse_time
46. What is the default value of max_input_time directive?
30 seconds
60 seconds
120 seconds
1 second
47. Since which version of PHP was the directive max_file_limit available.
PHP 5.2.1
PHP 5.2.2
PHP 5.2.12
PHP 5.2.21
48. What is the default value of the directive max_file_limit?
10 files
15 files
20 files
25 files
49. Which directive sets a maximum allowable amount of memory in megabytes that a script can allow
max_size
post_max_size
max_memory_limit
memory_limit
50. If you want to temporarily store uploaded files in the /tmp/phpuploads/ directory, which one of the following statement will you use?
upload_tmp_dir “/tmp/phpuploads/ directory”
upload_dir “/tmp/phpuploads/ directory
upload_temp_dir “/tmp/phpuploads/ directory”
upload_temp_director “/tmp/phpuploads/ directory”
Submit