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 2 - Which of the following type of variables are special variables that hold references to resources external to PHP (such as database connections)?

A - Strings

B - Arrays

C - Objects

D - Resources

Answer : D

Explanation

Resources: are special variables that hold references to resources external to PHP (such as database connections).

Q 3 - Which of the following magic constant of PHP returns function name?

A - _LINE_

B - _FILE_

C - _FUNCTION_

D - _CLASS_

Answer : C

Explanation

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

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

Answer : A

Explanation

PHP provided setcookie() function to set a cookie.

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 gives a string containing PHP script file name in which it is called?

A - $_PHP_SELF

B - $php_errormsg

C - $_COOKIE

D - $_SESSION

Answer : A

Explanation

$_PHP_SELF − A string containing PHP script file name in which it is called.

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