🐘

PHP MCQ

Test your PHP knowledge with 100 multiple choice questions covering fundamentals to advanced concepts, with instant feedback and explanations.

100 Questions 40 Beginner 40 Intermediate 20 Advanced
1

What does PHP stand for?

2

How do you start a PHP block of code?

3

How do you declare a variable in PHP?

4

Which function outputs text in PHP?

5

How do you write a single-line comment in PHP?

6

What is the concatenation operator in PHP?

7

How do you create an array in PHP?

8

What does isset() do?

9

What is the difference between == and === in PHP?

10

How do you define a function in PHP?

11

What does the count() function do?

12

Which PHP superglobal contains form data sent via POST?

13

What is a PHP class?

14

What does $this refer to inside a PHP class method?

15

How do you inherit from a class in PHP?

16

What is the purpose of the __construct() method?

17

What does the include statement do?

18

What is the output of var_dump(true)?

19

How do you access a value from an associative array?

20

What does PHP's null coalescing operator ?? do?

21

What is the difference between array_push() and $arr[] = ?

22

What is a PHP interface?

23

What is the scope of a variable defined inside a PHP function?

24

How do you convert a string to an integer in PHP?

25

What does empty() check in PHP?

26

What is the purpose of PHP sessions?

27

How do you call a static method in PHP?

28

What does the foreach loop do in PHP?

29

What is the PHP spaceship operator <=>?

30

What does htmlspecialchars() do?

31

What does the ternary operator look like in PHP?

32

What is a PHP trait?

33

What does unset() do?

34

Which function sorts an array in ascending order?

35

What is PHP's PDO?

36

What does the print_r() function do?

37

What is PHP type juggling?

38

What does declare(strict_types=1) do?

39

What are PHP magic methods?

40

What does str_replace() do?

1

What is the difference between abstract class and interface in PHP?

2

What is a PHP closure?

3

What is PHP's late static binding?

4

What is dependency injection in PHP?

5

What is a PHP generator?

6

What does PHP's array_map() do?

7

What are named arguments in PHP 8?

8

What is the match expression in PHP 8?

9

What is PHP's Fibers feature (PHP 8.1)?

10

What is PHP's union type declaration?

11

What are PHP attributes (PHP 8)?

12

What does PHP's null safe operator ?-> do?

13

What is the difference between include_once and require_once?

14

What is a PSR in PHP?

15

What is PSR-4 autoloading?

16

What is PHP's match expression's advantage over switch?

17

What is a PHP readonly property (PHP 8.1)?

18

What does PHP's splat operator ... do?

19

What is the difference between array_merge() and array + array?

20

What is PHP's object cloning?

21

What is a PHP enumeration (Enum) added in PHP 8.1?

22

What is PHP's SPL (Standard PHP Library)?

23

What is PHP's type coercion in strict mode?

24

What is the purpose of PHP's Composer?

25

What is PHP's arrow function (fn)?

26

What does PHP's intl extension provide?

27

What is PHP's Reflection API used for?

28

What is PHP's session fixation vulnerability?

29

What is PHP's Inversion of Control (IoC) container?

30

What is the difference between PHP's header() and setcookie()?

31

What is PHP's array_walk() function?

32

What does PHP's compact() do?

33

What is the purpose of PHP's final keyword on methods?

34

What is PHP's abstract static method debate?

35

What is PHP's output buffering?

36

What is PHP's DateTimeImmutable class?

37

What is PHP's splat in array unpacking?

38

What is PHP's first class callable syntax (PHP 8.1)?

39

What is PHP's fibers vs generators distinction?

40

What is the PHP serialize() vs json_encode() for data persistence?