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 floating-point numbers, like 3.14159 or 49.1?

A - Integers

B - Doubles

C - Booleans

D - Strings

Answer : B

Explanation

Doubles: are floating-point numbers, like 3.14159 or 49.1.

Q 4 - Which of the following array represents an array containing one or more arrays?

A - Numeric Array

B - Associative Array

C - Multidimentional Array

D - None of the above.

Answer : C

Explanation

Multidimensional array − An array containing one or more arrays and values are accessed using multiple indices.

Q 5 - Which of the following variable is used to generate random numbers using PHP?

A - srand()

B - rand()

C - random()

D - None of the above.

Answer : B

Explanation

The PHP rand() function is used to generate a random number. This function can generate numbers with-in a given range. The random number generator should be seeded to prevent a regular pattern of numbers being generated. This is achieved using the srand() function that specifiies the seed number as its argument.

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 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 associative array of variables passed to the current script via HTTP cookies?

A - $GLOBALS

B - $_SERVER

C - $_COOKIE

D - $_SESSION

Answer : C

Explanation

$_COOKIE − An associative array of variables passed to the current script via HTTP cookies.

Q 9 - Which of the following gives a string containing PHP script file name in which it is called?

A - $_PHP_SELF

B - $php_errormsg

C - $_COOKIE

D - $_SESSION

Answer : A

Explanation

$_PHP_SELF − A string containing PHP script file name in which it is called.

Q 10 - Which of the following method returns current date and time?

A - time()

B - getdate()

C - date()

D - None of the above

Answer : A

Explanation

PHP's time() function gives you all the information that you need about the current date and time. It requires no arguments but returns an integer.


php_questions_answers.htm

Advertisements