• 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 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 array represents an array with strings as index?

A - Numeric Array

B - Associative Array

C - Multidimentional Array

D - None of the above.

Answer : B

Explanation

Associative array − An array with strings as index. This stores element values in association with key values rather than in a strict linear index order.

Q 5 - Which of the following function is used to get environment variables in PHP?

A - search()

B - environment()

C - env()

D - getenv()

Answer : D

Explanation

PHP provides a function getenv() to access the value of all the environment variables.

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 the error code associated with this file upload?

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

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

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

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

Answer : A

Explanation

$_FILES['file']['error'] − it provides the error code associated with this file upload.

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 - final keyword prevents child classes from overriding a method by prefixing the definition with final?

A - true

B - false

Answer : A

Explanation

PHP 5 introduces the final keyword, which prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended.

php_questions_answers.htm
Advertisements