• PHP Video Tutorials

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

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 4 - Which of the following function is used to locate a string within a string?

A - search()

B - locate()

C - strpos()

D - None of the above.

Answer : C

Explanation

The strpos() function is used to search for a string or character within a string.

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 - If there is any problem in loading a file then the require() function generates a warning but the script will continue execution.

A - true

B - false

Answer : B

Explanation

If there is any problem in loading a file then the require() function generates a fatal error and halt the execution of the script.

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 content type of the uploaded file in PHP?

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

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

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

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

Answer : D

Explanation

$_FILES['file']['type'] − it provides the content type of the uploaded file in PHP.

Q 9 - Which of the following method of Exception class returns array of the backtrace?

A - getMessage()

B - getCode()

C - getTrace()

D - getTraceAsString()

Answer : C

Explanation

getTrace() method of Exception class returns array of the backtrace.

Q 10 - Which of the following method acts as a destructor function in a PHP class?

A - class_name()

B - __destruct

C - destructor

D - None of the above.

Answer : B

Explanation

Like a constructor function you can define a destructor function using function __destruct(). You can release all the resourceses with-in a destructor.

php_questions_answers.htm
Advertisements