Online admissions open for the SEO, PHP web development and networking & cybersecurity courses. Enquire for the next batch.

PHP Quiz: 12 Questions on PHP 8

Quiz · 12 questions Updated By the SkillNewton team

This free PHP quiz checks the knowledge you need to build secure, modern PHP applications: PHP 8 features such as match, the nullsafe operator and named arguments, strict types, arrays, superglobals, sessions, PDO prepared statements, password hashing, include versus require, comparison rules and escaping output against XSS. It suits students and junior developers. Answer all 12 questions, check your score, then read the explanations and revisit the PHP guide for anything you missed.

Choose one answer for each question, then check your score. Your answers stay in this browser and are not saved.

1. How does a match expression differ from switch?
2. What does $user?->getAddress()?->city return if $user is null?
3. What do named arguments, such as htmlspecialchars($text, double_encode: false), let you do?
4. A file starts with declare(strict_types=1); and calls add("5", 3), where add(int $a, int $b). What happens?
5. Given $a = ['k' => null]; which check returns true?
6. A form uses method="post". Where does PHP put its fields?
7. What must happen before you read or write $_SESSION?
8. Which approach safely queries users by an email address submitted in a form?
9. How should you store and check user passwords in PHP?
10. What is the difference between include and require when the file is missing?
11. In PHP 8, what does 0 == "foo" evaluate to?
12. What should you do before echoing a user's comment into an HTML page?

Frequently asked questions

Which PHP version does this quiz assume?

PHP 8.x. Some answers differ in PHP 7, for example how a number is compared with a non-numeric string.

Why are there security questions in a PHP quiz?

SQL injection, XSS and weak password storage are among the most common flaws in PHP applications, so prepared statements, escaping and password_hash() are core skills.

Do I need a framework to use these ideas?

No. Everything here is plain PHP. Frameworks such as CodeIgniter and Laravel build on the same features.

Want to Learn This Properly?

The PHP Web Development: Foundation & Practical Implementation (Online) turns resources like this into practised skills, with projects on real websites.

WhatsApp Call Us Now

Free counselling

Send an Enquiry

Tell us which course you are interested in. We reply by email or phone with the next batch and how to enrol.

We reply by email or phone within working hours. No spam.