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 instances of programmer-defined classes?

A - Strings

B - Arrays

C - Objects

D - Resources

Answer : C

Explanation

Objects: are instances of programmer-defined classes, which can package up both other kinds of values and functions that are specific to the class.

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 keyword causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating?

A - break

B - continue

Answer : B

Explanation

continue causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.

Q 5 - Which of the following is used to get information sent via get method in PHP?

A - $_GET

B - $GET

C - $GETREQUEST

D - None of the above.

Answer : A

Explanation

The PHP provides $_GET associative array to access all the sent information using GET method.

Q 6 - Which of the following function opens a file?

A - fopen()

B - fread()

C - filesize()

D - file_exist()

Answer : A

Explanation

The PHP fopen() function is used to open a file. It requires two arguments stating first the file name and then mode in which to operate.

Q 7 - Can you assign the default values to a function parameters?

A - true

B - false

Answer : A

Explanation

Yes! You can set a parameter to have a default value if the function's caller doesn't pass it.

Q 8 - Which of the following is used to destroy the session?

A - session_start() function

B - $_SESSION[]

C - isset() function

D - session_destroy() function

Answer : D

Explanation

A PHP session can be destroyed by session_destroy() function.

Q 9 - Which of the following method of Exception class returns source filename?

A - getMessage()

B - getCode()

C - getFile()

D - getLine()

Answer : C

Explanation

getFile() method of Exception class returns source filename.

Q 10 - Which of the following method can be used to create a MySql database using PHP?

A - mysql_connect()

B - mysql_query()

C - mysql_close()

D - None of the above

Answer : B

Explanation

PHP uses mysql_query function to create a MySQL database.


php_questions_answers.htm

Advertisements