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 instances of programmer-defined classes?

A - Strings

B - Arrays

C - Objects

D - Resources

Answer : C

Explanation

Objects: are instances of programmer-defined classes, which can package up both other kinds of values and functions that are specific to the class.

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 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 can be used to get an array in the reverse order?

A - array_reverse()

B - array_search()

C - array_shift()

D - array_slice()

Answer : A

Explanation

array_reverse() − Returns an array in the reverse order.

Q 6 - Which of the following function returns the sum of the values in an array?

A - array_sum()

B - array_splice()

C - array_udiff()

D - array_udiff_assoc()

Answer : A

Explanation

array_sum() − Returns the sum of the values in an array.

Q 7 - Which of the following function is used to get the size of a file?

A - fopen()

B - fread()

C - filesize()

D - file_exist()

Answer : C

Explanation

The files's length can be found using the filesize() function which takes the file name as its argument and returns the size of the file expressed in bytes.

Q 8 - Which of the following provides the error code associated with this file upload?

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

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

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

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

Answer : A

Explanation

$_FILES['file']['error'] − it provides the error code associated with this file upload.

Q 9 - Which of the following gives a string containing PHP script file name in which it is called?

A - $_PHP_SELF

B - $php_errormsg

C - $_COOKIE

D - $_SESSION

Answer : A

Explanation

$_PHP_SELF − A string containing PHP script file name in which it is called.

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