Quiz on PHP Language

1) What does PHP stand for?

a) Personal Home Page

b) Pretext Hypertext Processor

c) PHP: Hypertext Preprocessor

d) Programming Hyper Processor

Answer: c) PHP: Hypertext Preprocessor

2) In PHP, what function is used to check the length of a string?

a) str_length()

b) count()

c) len()

d) strlen()

Answer: d) strlen()

3) What type of variable is used to store a sequence of characters in PHP?

a) string

b) text

c) sequence

d) line

Answer: a) string

4) Which of the following is NOT a valid way to start a PHP variable name?

a) $

b) Letter

c) _

d) Number

Answer: d) Number

5) In PHP, how do you start a foreach loop for an array?

a) for_each ($array as $item)

b) foreach ($array as $item)

c) for ($array as $item)

d) loop ($array as $item)

Answer: b) foreach ($array as $item)

6) What PHP function is used to connect to a MySQL database?

a) mysql_connect()

b) db_connect()

c) mysqli_connect()

d) connect_mysql()

Answer: c) mysqli_connect()

7) Which operator is used for concatenating two strings in PHP?

a) .

b) +

c) &

d) ,

Answer: a) .

8) What function in PHP is used to redirect the user to a different URL?

a) redirect()

b) header_location()

c) forward()

d) location()

Answer: c) header_location()

9) What does the term "superglobals" refer to in PHP?

a) Variables accessible only within functions

b) Variables that can be accessed from any part of the script

c) Constants defined for global use

d) Reserved keywords in PHP

Answer: b) Variables that can be accessed from any part of the script

10) What is the default method for sending form data in PHP?

a) GET

b) POST

c) PUT

d) REQUEST

Answer: b) POST

11) Which PHP function is used to check if a file exists?

a) file_exist()

b) isfile()

c) file_exists()

d) checkfile()

Answer: c) file_exists()

12) How do you end a PHP statement?

a) ;

b) :

c) .

d) {}

Answer: a) ;

13) Which of the following is NOT a valid comparison operator in PHP?

a)<=>

b) ===

c) ><

d) !=

Answer: c) ><

14) What function in PHP is used to destroy a session?

a) session_end()

b) destroy_session()

c) session_destroy()

d) end_session()

Answer: c) session_destroy()

15) Which PHP function is used to find the position of the first occurrence of a substring within a string?

a) strpos()

b) strposition()

c) stringpos()

d) findpos()

Answer: a) strpos()

Explore Categories

JAVA

BOOTSTRAP

PYTHON

JAVASCRIPT

PHP

REACT

CSS

C & C++

HOMEPAGE