• 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 : D

Explanation

All of the above options are correct.

Q 2 - Which of the following type of variables are special type that only has one value: NULL?

A - Strings

B - Doubles

C - Booleans

D - NULL

Answer : D

Explanation

NULL: is a special type that only has one value: NULL.

Q 4 - Which of the following operator is used to concatenate two strings?

A - .

B - +

C - append

D - None of the above.

Answer : A

Explanation

To concatenate two string variables together, use the dot (.) operator.

Q 5 - Which of the following variable is used for the PHP script name?

A - $_PHP_SELF

B - $SELF

C - $PHP

D - None of the above.

Answer : A

Explanation

The PHP default variable $_PHP_SELF is used for the PHP script name and when you click "submit" button then same PHP script will be called.

Q 6 - If there is any problem in loading a file then the include() function generates a warning but the script will continue execution.

A - true

B - false

Answer : A

Explanation

If there is any problem in loading a file then the include() function generates a warning but the script will continue execution.

Answer : A

Explanation

PHP provided setcookie() function to set a cookie.

Q 8 - Which of the following is an associative array containing session variables available to the current script?

A - $GLOBALS

B - $_SERVER

C - $_COOKIE

D - $_SESSION

Answer : D

Explanation

$_SESSION − An associative array containing session variables available to the current script.

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 acts as a constructor function in a PHP class?

A - class_name()

B - __construct

C - constructor

D - None of the above.

Answer : B

Explanation

PHP provides a special function called __construct() to define a constructor. You can pass as many as arguments you like into the constructor function.

php_questions_answers.htm
Advertisements