• 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 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 function is used to get length of a string?

A - size()

B - strlen()

C - length

D - None of the above.

Answer : B

Explanation

The strlen() function is used to find the length of a string.

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 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 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 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 connect a MySql database using PHP?

A - mysql_connect()

B - mysql_query()

C - mysql_close()

D - None of the above

Answer : A

Explanation

PHP provides mysql_connect function to open a database connection.

php_questions_answers.htm
Advertisements