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

Q 2 - Which of the following type of variables have only two possible values either true or false?

A - Integers

B - Doubles

C - Booleans

D - Strings

Answer : C

Explanation

Booleans: have only two possible values either true or false.

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 function is used to redirect a page?

A - redirect()

B - header()

C - reflect()

D - None of the above.

Answer : B

Explanation

The PHP header() function supplies raw HTTP headers to the browser and can be used to redirect it to another location. The redirection script should be at the very top of the page to prevent any other part of the page from loading.

Q 6 - Doubly quoted strings are treated almost literally, whereas singly quoted strings replace variables with their values as well as specially interpreting certain character sequences.

A - true

B - false

Answer : B

Explanation

Singly quoted strings are treated almost literally, whereas doubly quoted strings replace variables with their values as well as specially interpreting certain character sequences.

Q 7 - Which of the following is used to access session variables in PHP?

A - session_start() function

B - $_SESSION[]

C - isset() function

D - session_destroy() function

Answer : B

Explanation

Session variables are stored in associative array called $_SESSION[]. These variables can be accessed during lifetime of a session.

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