1. What is PHP?
A) Database
B) Programming Language
C) Operating System
D) Web Browser
Answer: B
2. PHP stands for:
A) Personal Home Page
B) PHP: Hypertext Preprocessor
C) Private Hypertext Program
D) Programming Home Page
Answer: B
3. PHP was created by:
A) Rasmus Lerdorf
B) James Gosling
C) Guido van Rossum
D) Dennis Ritchie
Answer: A
4. PHP is mainly used for:
A) Web development
B) Hardware design
C) Operating systems
D) Game consoles only
Answer: A
5. PHP files have extension:
A) .html
B) .java
C) .php
D) .py
Answer: C
6. PHP code starts with:
A) <php>
B) <?php
C) <script>
D) <?
Answer: B
7. PHP code ends with:
A) ?>
B) </php>
C) </script>
D) ;
Answer: A
8. Which symbol is used before PHP variables?
A) #
B) @
C) $
D) &
Answer: C
9. Example of PHP variable:
A) name
B) $name
C) #name
D) @name
Answer: B
10. PHP is:
A) Server-side language
B) Client-side language
C) Database language
D) Markup language
Answer: A
11. Which command displays output?
A) echo
B) print
C) Both A and B
D) display
Answer: C
12. Correct PHP output statement:
A) echo “Hello”;
B) print “Hello”;
C) Both
D) output “Hello”;
Answer: C
13. PHP statements end with:
A) :
B) ;
C) .
D) ,
Answer: B
14. Single-line comments use:
A) //
B) #
C) Both A and B
D) <!– –>
Answer: C
15. Multi-line comments:
A) /* */
B) //
C) ##
D) <>
Answer: A
16. Which function shows variable information?
A) print_r()
B) show()
C) display()
D) info()
Answer: A
17. Which function returns variable type?
A) typeof()
B) gettype()
C) type()
D) datatype()
Answer: B
18. PHP variables are:
A) Strongly typed
B) Dynamically typed
C) Fixed typed
D) Untyped only
Answer: B
19. Which is a valid variable name?
A) $1name
B) $my-name
C) $my_name
D) $class
Answer: C
20. PHP variable names are:
A) Case sensitive
B) Case insensitive
C) Always uppercase
D) Always lowercase
Answer: A
21. Which data type stores text?
A) int
B) string
C) float
D) bool
Answer: B
22. Which stores integers?
A) integer
B) int
C) number
D) Both A and B
Answer: D
23. Which stores decimal values?
A) float
B) double
C) Both A and B
D) decimal
Answer: C
24. Boolean values are:
A) yes/no
B) true/false
C) 1/2
D) on/off only
Answer: B
25. NULL represents:
A) Empty value
B) Zero
C) False only
D) Error
Answer: A
26. Which function checks data type?
A) is_type()
B) gettype()
C) datatype()
D) typeof()
Answer: B
27. String concatenation operator:
A) +
B) .
C) &
D) *
Answer: B
28. Output of:
echo "Hello"." World";
A) Hello
B) World
C) Hello World
D) Error
Answer: C
29. Which converts to integer?
A) integer()
B) int()
C) (int)
D) convert()
Answer: C
30. Which converts to string?
A) str()
B) (string)
C) string()
D) text()
Answer: B
31. Array in PHP stores:
A) One value
B) Multiple values
C) Only numbers
D) Only strings
Answer: B
32. Creating an array:
A) array()
B) []
C) Both
D) list() only
Answer: C
33. First array index:
A) 1
B) 0
C) -1
D) 2
Answer: B
34. Function to count array elements:
A) count()
B) length()
C) size()
D) total()
Answer: A
35. Add element to array:
A) add()
B) append()
C) array_push()
D) push()
Answer: C
36. Remove last array element:
A) remove()
B) array_pop()
C) delete()
D) pop()
Answer: B
37. Associative arrays use:
A) Indexes
B) Keys
C) Numbers only
D) Classes
Answer: B
38. Loop through array:
A) foreach
B) for
C) while
D) All of them
Answer: D
39. foreach is used for:
A) Arrays
B) Conditions
C) Classes only
D) Errors
Answer: A
40. Sorting arrays:
A) sort()
B) arrange()
C) order()
D) sorting()
Answer: A
41. Decision statement:
A) if
B) for
C) function
D) class
Answer: A
42. Alternative condition:
A) else
B) otherwise
C) switch
D) case
Answer: A
43. Multiple conditions:
A) switch
B) if only
C) loop
D) foreach
Answer: A
44. Loop with condition:
A) while
B) if
C) class
D) include
Answer: A
45. Loop executes once minimum:
A) for
B) while
C) do-while
D) foreach
Answer: C
46. Exit loop:
A) stop
B) break
C) exitloop
D) quit
Answer: B
47. Skip iteration:
A) continue
B) skip
C) pass
D) next
Answer: A
48. Equality operator:
A) =
B) ==
C) ===
D) Both B and C
Answer: D
49. Assignment operator:
A) =
B) ==
C) ===
D) !=
Answer: A
50. Strict comparison uses:
A) ==
B) ===
C) =
D) <>
Answer: B
51. Function definition keyword:
A) function
B) def
C) func
D) method
Answer: A
52. Function returns value using:
A) send
B) return
C) output
D) give
Answer: B
53. Calling a function:
A) function()
B) call function
C) run()
D) execute only
Answer: A
54. Built-in PHP functions:
A) Already available
B) Must be created
C) Not allowed
D) Only database functions
Answer: A
55. Number of arguments in function:
A) Fixed only
B) Can vary
C) Always zero
D) Not possible
Answer: B
56. Object-Oriented PHP uses:
A) Classes
B) Objects
C) Both
D) Only functions
Answer: C
57. Creating class:
A) class
B) object
C) new
D) create
Answer: A
58. Creating object:
A) create
B) new
C) object
D) make
Answer: B
59. Constructor method:
A) __construct()
B) constructor()
C) init()
D) start()
Answer: A
60. Destructor method:
A) __delete()
B) __destruct()
C) destroy()
D) remove()
Answer: B
61. Inheritance keyword:
A) extends
B) inherits
C) implements
D) parent
Answer: A
62. Interface keyword:
A) interface
B) class
C) abstract
D) trait
Answer: A
63. Current object:
A) this
B) self
C) $this
D) current
Answer: C
64. Static keyword:
A) static
B) fixed
C) const
D) final
Answer: A
65. Constant declaration:
A) constant
B) define()
C) const
D) Both B and C
Answer: D
66. Database commonly used with PHP:
A) MySQL
B) HTML
C) CSS
D) XML
Answer: A
67. PHP database extension:
A) PDO
B) SQL
C) HTML
D) CSS
Answer: A
68. SQL query execution:
A) mysqli_query()
B) mysql_run()
C) querySQL()
D) executeSQL()
Answer: A
69. Form data method:
A) GET
B) POST
C) Both
D) SEND
Answer: C
70. GET sends data through:
A) URL
B) Database
C) Cookie
D) Server memory
Answer: A
71. POST sends data:
A) In URL
B) In request body
C) In HTML
D) In CSS
Answer: B
72. Access GET data:
A) $_GET
B) $_POST
C) $_FORM
D) $_DATA
Answer: A
73. Access POST data:
A) $_GET
B) $_POST
C) $_REQUESTS
D) $_SEND
Answer: B
74. Session variable:
A) $_SESSION
B) $_COOKIE
C) $_SERVER
D) $_SESSION[]
Answer: A
75. Cookie function:
A) setcookie()
B) cookie()
C) makecookie()
D) createcookie()
Answer: A
76. Include another file:
A) include
B) import
C) require
D) Both A and C
Answer: D
77. require differs because:
A) Stops on failure
B) Ignores errors
C) Deletes file
D) Runs faster always
Answer: A
78. Redirect header:
A) header()
B) redirect()
C) move()
D) location()
Answer: A
79. Start session:
A) session_start()
B) start_session()
C) begin()
D) session()
Answer: A
80. PHP server commonly:
A) Apache
B) Nginx
C) Both
D) None
Answer: C
81. Error handling function:
A) error_reporting()
B) error()
C) handleError()
D) catchError()
Answer: A
82. Exception handling:
A) try/catch
B) if/else
C) switch
D) loop
Answer: A
83. Throw exception:
A) throw
B) raise
C) error
D) exception
Answer: A
84. JSON conversion:
A) json_encode()
B) json_decode()
C) Both
D) json()
Answer: C
85. Convert JSON to PHP:
A) json_decode()
B) json_encode()
C) decode()
D) parse()
Answer: A
86. PHP is an:
A) Open-source language
B) Closed-source language
C) Hardware language
D) Database
Answer: A
87. Latest PHP versions belong to:
A) PHP 1
B) PHP 3
C) PHP 8+
D) PHP 0
Answer: C
88. PHP runs on:
A) Server
B) Browser only
C) Client only
D) Keyboard
Answer: A
89. HTML is generated by PHP:
A) Yes
B) No
C) Never
D) Only CSS
Answer: A
90. PHP can create:
A) Dynamic web pages
B) Static files only
C) Images only
D) Databases only
Answer: A
91. File opening function:
A) fopen()
B) open()
C) fileopen()
D) readfile()
Answer: A
92. Read file:
A) fread()
B) read()
C) getfile()
D) openread()
Answer: A
93. Write file:
A) fwrite()
B) write()
C) save()
D) put()
Answer: A
94. Check file exists:
A) file_exists()
B) exists()
C) checkfile()
D) isfile()
Answer: A
95. Remove file:
A) delete()
B) unlink()
C) remove()
D) erase()
Answer: B
96. PHP arrays can contain:
A) Different data types
B) Only integers
C) Only strings
D) Only objects
Answer: A
97. PHP supports:
A) Procedural programming
B) Object-oriented programming
C) Both
D) Neither
Answer: C
98. Composer is:
A) PHP dependency manager
B) Database
C) Browser
D) Server
Answer: A
99. Laravel is:
A) PHP framework
B) Database
C) Language
D) Browser
Answer: A
100. PHP is mainly used to build:
A) Websites and web applications
B) Operating systems only
C) Drivers only
D) Games only
Answer: A