• 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 whole numbers, without a decimal point, like 4195?

A - Integers

B - Doubles

C - Booleans

D - Strings

Answer : A

Explanation

Integers: are whole numbers, without a decimal point, like 4195.

Q 4 - Which of the following magic constant of PHP returns class name?

A - _LINE_

B - _FILE_

C - _FUNCTION_

D - _CLASS_

Answer : D

Explanation

_CLASS_ − The class name. (Added in PHP 4.3.0) As of PHP 5 this constant returns the class name as it was declared (case-sensitive). In PHP 4 its value is always lowercased.

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 - 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 check if session variable is already set or not in PHP?

A - session_start() function

B - $_SESSION[]

C - isset() function

D - session_destroy() function

Answer : C

Explanation

Make use of isset() function to check if session variable is already set or not.

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