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 1 - Is PHP whitespace sensitive?

A - false

B - true

Answer : A

Explanation

false! PHP is whitespace insensitive means that it almost never matters how many whitespace characters you have in a row.one whitespace character is the same as many such characters.

Answer : D

Explanation

All of the above options are correct.

Q 4 - Which of the following array represents an array with strings as index?

A - Numeric Array

B - Associative Array

C - Multidimentional Array

D - None of the above.

Answer : B

Explanation

Associative array − An array with strings as index. This stores element values in association with key values rather than in a strict linear index order.

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 get cookies?

A - getcookie() function

B - $_COOKIE variable

C - isset() function

D - None of the above.

Answer : B

Explanation

PHP provides many ways to access cookies. Simplest way is to use either $_COOKIE or $HTTP_COOKIE_VARS variables.

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 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 returns a formatted string representing a date?

A - time()

B - getdate()

C - date()

D - None of the above

Answer : C

Explanation

The date() function returns a formatted string representing a date. You can exercise an enormous amount of control over the format that date() returns with a string argument that you must pass to it.

php_questions_answers.htm
Advertisements