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 sequences of characters, like 'PHP supports string operations.'?

A - Strings

B - Arrays

C - Objects

D - Resources

Answer : A

Explanation

Strings: are sequences of characters, like 'PHP supports string operations.'

Answer : C

Explanation

Both 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 can be used to get information sent via get/post method in PHP?

A - $_REQUEST

B - $REQUEST

C - $REQUEST_PAGE

D - None of the above.

Answer : A

Explanation

The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.

Q 6 - Which of the following function is used to read the content of a file?

A - fopen()

B - fread()

C - filesize()

D - file_exist()

Answer : B

Explanation

Once a file is opened using fopen() function it can be read with a function called fread(). This function requires two arguments. These must be the file pointer and the length of the file expressed in bytes.

Q 7 - Can you assign the default values to a function parameters?

A - true

B - false

Answer : A

Explanation

Yes! You can set a parameter to have a default value if the function's caller doesn't pass it.

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 retrieve the error message when error occured?

A - getMessage()

B - getCode()

C - getFile()

D - getLine()

Answer : A

Explanation

getMessage() method of Exception class returns the message of exception.

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
E-Books Store