1. Which function sets the file filename’s last-modified and last-accessed times?
a) touched()
b) touch()
c) sets()
d) set()
Discussion
Explanation: Its prototype is int touch(string filename [, int time [, int atime]]). It returns TRUE on success or FALSE on error.
2. Which one is not a data type in PHP?
a) Resources
b) Objects
c) Null
d) Void
Discussion
Explanation: The void is not a data type in PHP.
3. [:alpha:] can also be specified as.
a) [A-Za-z0-9]
b) [A-za-z]
c) [A-z]
d) [a-z]
Discussion
Explanation: [:alpha:] is nothing but Lowercase and uppercase alphabetical characters.
4. Which one of the following function reads a directory into an Array?
a) scandir()
b) readdir()
c) scandirectory()
d) readdirectory()
Discussion
Explanation: It returns an array consisting of files and directories found in directory or returns FALSE on error.
5. How many functions does PHP offer for searching strings using POSIX style regular expression?
a) 7
b) 8
c) 9
d) 10
Discussion
Explanation: ereg(), ereg_replace(), eregi(), eregi_replace(), split(), spliti(), and sql_regcase() are the functions offered.
6. A function in PHP which starts with __ (double underscore) is known as.
a) Magic Function
b) Inbuilt Function
c) Default Function
d) User Defined Function
Discussion
Explanation: PHP functions that start with a double underscore – a “__” – are called magic functions in PHP. They are functions that are always defined inside classes, and are not stand-alone functions.
7. Which loop evaluates the condition expression as Boolean, if it is true, it executes the statements and when it is false it will terminate?
a) For loop
b) while loop
c) do-while loop
d) All of the above
Discussion
Explanation: While loop evaluates the condition expression as Boolean, if it is true, it executes the statements and when it is false it will terminate.
8. Which of the following PHP functions can be used for generating unique id’s?
a) id()
b) md5()
c) mdid()
d) uniqueid()
Discussion
Explanation: Many people use the md5() function for this, even though it’s not exactly meant for this purpose. uniqueid() is the function that is to be used.
9. 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()
Discussion
Explanation: The string is broken up into different values in the array based upon your input.
10. Which one of the following functions can be used to compress a string?
a) zip()
b) compress()
c) gzcompress()
d) zip_compress()
Discussion
Explanation: We will be able to achieve almost 50% size reduction using this function. The gzuncompress() function is used to uncompress the string.