• 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 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 3 - Which of the following magic constant of PHP returns full path and filename of the file?

A - _LINE_

B - _FILE_

C - _FUNCTION_

D - _CLASS_

Answer : B

Explanation

_FILE_ − The full path and filename of the file. If used inside an include,the name of the included file is returned. Since PHP 4.0.2, _FILE_ always contains an absolute path whereas in older versions it contained relative path under some circumstances.

Q 4 - Which of the following function is used to get length of a string?

A - size()

B - strlen()

C - length

D - None of the above.

Answer : B

Explanation

The strlen() function is used to find the length of a string.

Q 5 - Which of the following function sorts an array in reverse order?

A - rsort()

B - sort()

C - shuffle()

D - reset()

Answer : A

Explanation

rsort() − Sorts an array in reverse order.

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

A - true

B - false

Answer : B

Explanation

If there is any problem in loading a file then the require() function generates a fatal error and halt the execution of the script.

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 actual name of the uploaded file?

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

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

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

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

Answer : B

Explanation

$_FILES['file']['name'] − it provides the actual name of the uploaded file.

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