• 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

Answer : D

Explanation

All of the above options are correct.

Q 4 - Which of the following keyword terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch?

A - break

B - continue

Answer : A

Explanation

break terminates the for loop or switch statement and transfers execution to the statement immediately following the for loop or switch.

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.

Answer : A

Explanation

To concatenate two string variables together, use the dot (.) operator.

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 contains a reference to every variable which is currently available within the global scope of the script?

A - $GLOBALS

B - $_SERVER

C - $_COOKIE

D - $_SESSION

Answer : A

Explanation

$GLOBALS − Contains a reference to every variable which is currently available within the global scope of the script. The keys of this array are the names of the global variables.

Q 10 - final keyword prevents child classes from overriding a method by prefixing the definition with final?

A - true

B - false

Answer : A

Explanation

PHP 5 introduces the final keyword, which prevents child classes from overriding a method by prefixing the definition with final. If the class itself is being defined final then it cannot be extended.

php_questions_answers.htm
Advertisements