• 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

Q 2 - Which of the following type of variables are sequences of characters, like 'PHP supports string operations.'?

A - Strings

B - Arrays

C - Objects

D - Resources

Answer : A

Explanation

Strings: are sequences of characters, like 'PHP supports string operations.'

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 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 - Which of the following function returns selected parts of an array?

A - array_reverse()

B - array_search()

C - array_shift()

D - array_slice()

Answer : D

Explanation

array_slice() − Returns selected parts of an array.

Q 7 - Which of the following is used to delete a cookie?

A - setcookie() function

B - $_COOKIE variable

C - isset() function

D - None of the above.

Answer : A

Explanation

To delete a cookie you should call setcookie() with the name argument only.

Q 8 - Which of the following provides the size of the uploaded file in PHP?

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

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

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

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

Answer : C

Explanation

$_FILES['file']['size'] − it provides the size 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 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