PHP Online Quiz


Advertisements


Following quiz provides Multiple Choice Questions (MCQs) related to PHP. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Answer : D

Explanation

All of the above options are correct.

Q 2 - Which of the following type of variables are named and indexed collections of other values?

A - Strings

B - Arrays

C - Objects

D - Resources

Answer : B

Explanation

Arrays: are named and indexed collections of other values.

Q 4 - Which of the following array represents an array with strings as index?

A - Numeric Array

B - Associative Array

C - Multidimentional Array

D - None of the above.

Answer : B

Explanation

Associative array − An array with strings as index. This stores element values in association with key values rather than in a strict linear index order.

Q 5 - Which of the following function sorts an array in reverse order?

A - rsort()

B - sort()

C - shuffle()

D - reset()

Answer : A

Explanation

rsort() − Sorts an array in reverse order.

Q 6 - Which of the following function opens a file?

A - fopen()

B - fread()

C - filesize()

D - file_exist()

Answer : A

Explanation

The PHP fopen() function is used to open a file. It requires two arguments stating first the file name and then mode in which to operate.

Q 7 - Which of the following function is used to get the size of a file?

A - fopen()

B - fread()

C - filesize()

D - file_exist()

Answer : C

Explanation

The files's length can be found using the filesize() function which takes the file name as its argument and returns the size of the file expressed in bytes.

Q 8 - Which of the following provides access to the uploaded file in the temporary directory on the web server?

A - $_FILES['file']['tmp_name']

B - $_FILES['file']['name']

C - $_FILES['file']['size']

D - $_FILES['file']['type']

Answer : A

Explanation

$_FILES['file']['tmp_name'] − it provides access to the uploaded file in the temporary directory on the web server.

Q 9 - Which of the following method of Exception class returns the code of exception when error occured?

A - getMessage()

B - getCode()

C - getFile()

D - getLine()

Answer : B

Explanation

getCode() method of Exception class returns the code of exception.

Q 10 - Which of the following method returns current date and time?

A - time()

B - getdate()

C - date()

D - None of the above

Answer : A

Explanation

PHP's time() function gives you all the information that you need about the current date and time. It requires no arguments but returns an integer.


php_questions_answers.htm

Advertisements