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 4 - Which of the following keyword terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch?

A - break

B - continue

Answer : A

Explanation

break terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch.

Q 5 - Which of the following is used to get information sent via get method in PHP?

A - $_GET

B - $GET

C - $GETREQUEST

D - None of the above.

Answer : A

Explanation

The PHP provides $_GET associative array to access all the sent information using GET method.

Q 6 - Which of the following function returns the sum of the values in an array?

A - array_sum()

B - array_splice()

C - array_udiff()

D - array_udiff_assoc()

Answer : A

Explanation

array_sum() − Returns the sum of the values in an array.

Q 7 - Which of the following is used to get cookies?

A - getcookie() function

B - $_COOKIE variable

C - isset() function

D - None of the above.

Answer : B

Explanation

PHP provides many ways to access cookies. Simplest way is to use either $_COOKIE or $HTTP_COOKIE_VARS variables.

Q 8 - Which of the following provides the actual name of the uploaded file?

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

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

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

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

Answer : B

Explanation

$_FILES['file']['name'] − it provides the actual name of the uploaded file.

Q 9 - Which of the following method of Exception class retrieve the error message when error occured?

A - getMessage()

B - getCode()

C - getFile()

D - getLine()

Answer : A

Explanation

getMessage() method of Exception class returns the message 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