• 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 3 - Which of the following magic constant of PHP returns full path and filename of the file?

A - _LINE_

B - _FILE_

C - _FUNCTION_

D - _CLASS_

Answer : B

Explanation

_FILE_ − The full path and filename of the file. If used inside an include,the name of the included file is returned. Since PHP 4.0.2, _FILE_ always contains an absolute path whereas in older versions it contained relative path under some circumstances.

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 function creates an array?

A - array()

B - array_change_key_case()

C - array_chunk()

D - array_count_values()

Answer : A

Explanation

array() − Creates an array.

Q 6 - Which of the following function returns the sum of the values in an array?

A - array_sum()

B - array_splice()

C - array_udiff()

D - array_udiff_assoc()

Answer : A

Explanation

array_sum() − Returns the sum of the values in an array.

Q 7 - Which of the following is used to check that a cookie is set or not?

A - getcookie() function

B - $_COOKIE variable

C - isset() function

D - None of the above.

Answer : C

Explanation

You can use isset() function to check if a cookie is set or not.

Q 8 - Which of the following is an array containing information such as headers, paths, and script locations?

A - $GLOBALS

B - $_SERVER

C - $_COOKIE

D - $_SESSION

Answer : B

Explanation

$_SERVER − This is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these. See next section for a complete list of all the SERVER variables.

Q 9 - Which of the following method of Exception class returns formated string of trace?

A - getMessage()

B - getCode()

C - getTrace()

D - getTraceAsString()

Answer : D

Explanation

getTraceAsString() method of Exception class returns formated string of trace.

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