• PHP Video Tutorials

PHP Online Quiz



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 : C

Explanation

Both of the above options are correct.

Q 4 - Which of the following function is used to get length of a string?

A - size()

B - strlen()

C - length

D - None of the above.

Answer : B

Explanation

The strlen() function is used to find the length of a string.

Q 5 - Which of the following variable is used to get user's browser and operating system details in PHP?

A - HTTP_USER_AGENT

B - USER

C - AGENT

D - None of the above.

Answer : A

Explanation

One of the environemnt variables set by PHP is HTTP_USER_AGENT which identifies the user's browser and operating system.

Q 6 - Which of the following function returns selected parts of an array?

A - array_reverse()

B - array_search()

C - array_shift()

D - array_slice()

Answer : D

Explanation

array_slice() − Returns selected parts of an array.

Q 7 - Which of the following is used to check that a cookie is set or not?

A - getcookie() function

B - $_COOKIE variable

C - isset() function

D - None of the above.

Answer : C

Explanation

You can use isset() function to check if a cookie is set or not.

Q 8 - Which of the following provides content type of the uploaded file in PHP?

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

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

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

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

Answer : D

Explanation

$_FILES['file']['type'] − it provides the content type of the uploaded file in PHP.

Q 9 - Which of the following method of Exception class returns formated string of trace?

A - getMessage()

B - getCode()

C - getTrace()

D - getTraceAsString()

Answer : D

Explanation

getTraceAsString() method of Exception class returns formated string of trace.

Q 10 - Which of the following method can be used to parse an XML document using PHP?

A - simplexml_load_string()

B - loadxml()

C - Both of the above.

D - None of the above.

Answer : C

Explanation

To create a SimpleXML object from an XML document stored in a string, pass the string to simplexml_load_string( ). It returns a SimpleXML object.

php_questions_answers.htm
Advertisements