• PHP Video Tutorials

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 1 - Is PHP whitespace sensitive?

A - false

B - true

Answer : A

Explanation

false! PHP is whitespace insensitive means that it almost never matters how many whitespace characters you have in a row.one whitespace character is the same as many such characters.

Q 2 - Which of the following type of variables have only two possible values either true or false?

A - Integers

B - Doubles

C - Booleans

D - Strings

Answer : C

Explanation

Booleans: have only two possible values either true or false.

Q 3 - Which of the following magic constant of PHP returns current line number of the file?

A - _LINE_

B - _FILE_

C - _FUNCTION_

D - _CLASS_

Answer : A

Explanation

_LINE_ − The current line number of the file.

Q 4 - Which of the following array represents an array containing one or more arrays?

A - Numeric Array

B - Associative Array

C - Multidimentional Array

D - None of the above.

Answer : C

Explanation

Multidimensional array − An array containing one or more arrays and values are accessed using multiple indices.

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 opens a file?

A - fopen()

B - fread()

C - filesize()

D - file_exist()

Answer : A

Explanation

The PHP fopen() function is used to open a file. It requires two arguments stating first the file name and then mode in which to operate.

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 containing session variables available to the current script?

A - $GLOBALS

B - $_SERVER

C - $_COOKIE

D - $_SESSION

Answer : D

Explanation

$_SESSION − An associative array containing session variables available to the current script.

Q 9 - Which of the following method of Exception class returns source line?

A - getMessage()

B - getCode()

C - getFile()

D - getLine()

Answer : D

Explanation

getLine() method of Exception class returns source line.

Q 10 - Which of the following method connect a MySql database using PHP?

A - mysql_connect()

B - mysql_query()

C - mysql_close()

D - None of the above

Answer : A

Explanation

PHP provides mysql_connect function to open a database connection.

php_questions_answers.htm
Advertisements