• 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

Q 2 - Which of the following type of variables are special type that only has one value: NULL?

A - Strings

B - Doubles

C - Booleans

D - NULL

Answer : D

Explanation

NULL: is a special type that only has one value: NULL.

Q 4 - Which of the following operator is used to concatenate two strings?

A - .

B - +

C - append

D - None of the above.

Answer : A

Explanation

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

Q 5 - Which of the following function is used to redirect a page?

A - redirect()

B - header()

C - reflect()

D - None of the above.

Answer : B

Explanation

The PHP header() function supplies raw HTTP headers to the browser and can be used to redirect it to another location. The redirection script should be at the very top of the page to prevent any other part of the page from loading.

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 function is used to check if a file exists or not?

A - fopen()

B - fread()

C - filesize()

D - file_exist()

Answer : D

Explanation

File's existence can be confirmed using file_exist() function which takes file name as an argument.

Q 8 - Which of the following provides the size of the uploaded file in PHP?

A - $_FILES['file']['tmp_name']

B - $_FILES['file']['name']

C - $_FILES['file']['size']

D - $_FILES['file']['type']

Answer : C

Explanation

$_FILES['file']['size'] − it provides the size of the uploaded file in PHP.

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 acts as a constructor function in a PHP class?

A - class_name()

B - __construct

C - constructor

D - None of the above.

Answer : B

Explanation

PHP provides a special function called __construct() to define a constructor. You can pass as many as arguments you like into the constructor function.

php_questions_answers.htm
Advertisements