Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

PHP interviews often begin by establishing which PHP you have written, because the language changed substantially between version 5 and version 8. Expect questions on loose versus strict comparison, prepared statements and injection defence, session handling behind a load balancer, interfaces, abstract classes and traits, Composer and PSR-4 autoloading, and the PHP 8 features that changed how modern code is written. Security and performance judgement feature throughout. The questions below cover all of it.

Php MCQ

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

2.In PHP 8, what is the result of 0 == "foo"?

3.What is the difference between require and include?

4.Which is the strongest defence against SQL injection in PHP?

5.Which PDO attribute should be set so query failures raise exceptions?

6.Why should PDO::ATTR_EMULATE_PREPARES be set to false?

7.Which function correctly escapes output for HTML context?

8.Which PHP function should be used to hash a user password?

9.Which function verifies a password against a stored hash?

10.What must be called immediately after a successful login to prevent session fixation?

11.Why do PHP sessions break behind a load balancer by default?

12.What does Composer's autoload PSR-4 mapping do?

13.Which command should be used to install dependencies during deployment?

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

15.What is a trait in PHP used for?

16.In PHP 7 and later, which type should be caught to handle both exceptions and errors?

17.What does the finally block guarantee?

18.Which superglobal contains data submitted via an HTML form using the POST method?

19.Why is POST not inherently more secure than GET?

20.What is the correct approach to validating a file upload?

21.What does OPcache do?

22.Which PHP 8 feature reduces boilerplate by declaring and assigning properties in the constructor signature?

23.What does the readonly property modifier introduced in PHP 8.1 do?

24.How does the match expression differ from a switch statement?

25.What does declare(strict_types=1) do?

26.Which of these correctly checks whether an array key exists, including when its value is null?

27.What is the difference between echo and print in PHP?

28.Which function safely compares two hashes or tokens?

29.What is a namespace in PHP used for?

30.Which is an appropriate use of a static method?

31.What does the spaceship operator (<=>) return?

32.Which PHP setting must be disabled in production to avoid leaking stack traces?

33.What is the purpose of a CSRF token in a PHP form?

34.Which array function applies a callback to every element and returns a new array?

35.What does the null coalescing operator (??) do?

36.What is an enum in PHP 8.1 used for?

37.Which of these best describes PSR-12?

39.What does the nullsafe operator (?->) do?

40.Which of these is the correct return type declaration for a function that may return an integer or null?

41.What is the most common cause of an unexpectedly slow PHP application?

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as