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 floating-point numbers, like 3.14159 or 49.1?

A - Integers

B - Doubles

C - Booleans

D - Strings

Answer : B

Explanation

Doubles: are floating-point numbers, like 3.14159 or 49.1.

Q 3 - Which of the following magic constant of PHP returns current line number of the file?

A - _LINE_

B - _FILE_

C - _FUNCTION_

D - _CLASS_

Answer : A

Explanation

_LINE_ − The current line number of the file.

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

A - _METHOD_

B - _FILE_

C - _FUNCTION_

D - _CLASS_

Answer : A

Explanation

_METHOD_ − The class method name. (Added in PHP 5.0.0) The method name is returned as it was declared (case-sensitive).

Q 5 - Which of the following can be used to get information sent via get/post method in PHP?

A - $_REQUEST

B - $REQUEST

C - $REQUEST_PAGE

D - None of the above.

Answer : A

Explanation

The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.

Q 6 - Which of the following function checks if a specified value exists in an array?

A - extract()

B - in_array()

C - key()

D - krsort()

Answer : B

Explanation

in_array() − Checks if a specified value exists in 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 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