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

Answer : C

Explanation

Both of the above options are correct.

Q 4 - Which of the following array represents an array with a numeric index?

A - Numeric Array

B - Associative Array

C - Multidimentional Array

D - None of the above.

Answer : A

Explanation

Numeric array − An array with a numeric index. Values are stored and accessed in linear fashion.

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

A - true

B - false

Answer : A

Explanation

If there is any problem in loading a file then the include() function generates a warning but the script will continue execution.

Q 7 - Which of the following is used to access session variables in PHP?

A - session_start() function

B - $_SESSION[]

C - isset() function

D - session_destroy() function

Answer : B

Explanation

Session variables are stored in associative array called $_SESSION[]. These variables can be accessed during lifetime of a session.

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 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 can be used to close a MySql database using PHP?

A - mysql_connect()

B - mysql_query()

C - mysql_close()

D - None of the above

Answer : C

Explanation

PHP uses mysql_close function to close a MySQL database.

php_questions_answers.htm
Advertisements