CoreHRx Jobs

Apply in one click, save jobs and take free mock tests.

Register free Log in
Hiring? Post jobs with CoreHRx
My account
user

View & update profile

PHP and MySQL mock test: free online practice

30 random questions, 30 minutes, at the level you choose: php 8, pdo, security, sql queries, indexes and laravel. After you submit you get your score, your strong and weak topics, and the right answer with an explanation for every question.

Want to revise first? Read the PHP and MySQL interview questions and answers.

Choose your experience

Free with a CoreHRx Jobs account: you will be asked to sign in or create one first.

What does the PHP and MySQL mock test cover?

The test draws on 300 PHP and MySQL questions in 12 topics, across three levels. Each attempt picks 30 of them at random for the level you choose.

  • SQL Queries27 Qs
  • Indexes26 Qs
  • PHP Core26 Qs
  • Security26 Qs
  • Laravel25 Qs
  • OOP25 Qs
  • Transactions25 Qs
  • Arrays24 Qs
  • PDO24 Qs
  • Scaling24 Qs
  • Schema Design24 Qs
  • Sessions24 Qs

Sample PHP and MySQL mock test questions

One question from each level, the way they appear in the test. Try it, then open the answer.

  1. FresherPHP Core

    What does this code print in PHP 8?

    var_dump("abc" == 0);
    • bool(false)
    • bool(true)
    • int(0)
    • A TypeError is thrown
    Show the answer

    Answer: bool(false). Since PHP 8, comparing a non-numeric string with a number converts the number to a string and compares strings, so "abc" == 0 is false. In PHP 7 the string was cast to 0 and the result was true, which caused many bugs.

  2. Intermediate (1-5 years)Arrays

    What does this code print?

    $e = [['n' => 'A', 's' => 300], ['n' => 'B', 's' => 100], ['n' => 'C', 's' => 200]];
    usort($e, fn ($x, $y) => $y['s'] <=> $x['s']);
    echo implode(',', array_column($e, 'n'));
    • B,C,A
    • A,B,C
    • C,A,B
    • A,C,B
    Show the answer

    Answer: A,C,B. The spaceship operator returns -1, 0 or 1. Putting $y before $x reverses the order, so the rows are sorted by s from highest to lowest: 300, 200, 100. array_column() then picks the n values.

  3. Experienced (5+ years)OOP

    ReadOnlyStorage extends Storage and throws an exception in write(), while Storage::write() works normally. Which principle does this break?

    • Liskov substitution: code that expects a Storage can no longer use the subclass safely
    • Dependency inversion: the subclass depends on a concrete class
    • Interface segregation: the subclass has too many methods
    • Open/closed: the parent class was modified
    Show the answer

    Answer: Liskov substitution: code that expects a Storage can no longer use the subclass safely. A subclass must honour the parent's contract, so any code written for Storage keeps working when given a subclass. A write() that always fails breaks callers. Better: separate ReadableStorage and WritableStorage interfaces, and let the read-only class implement only the first.

Take the full PHP and MySQL mock test: 30 questions, 30 minutes.

How is the PHP and MySQL mock test scored?

A question counts as right only when you pick exactly the right option, or all the right options where it says so; a question left blank counts as wrong. Your score is the share of the 30 questions you got right. The result also scores every topic, so you know what to revise before the interview.

  • 75% or more in a topica strength
  • 50% to 74%worth a revision
  • Under 50%a topic to work on

PHP and MySQL mock test: questions people ask

Is the PHP and MySQL mock test free?

Yes. The PHP and MySQL mock test is free. You need a free CoreHRx Jobs account to start it, so your score and the topics to work on are saved.

How many questions are in the PHP and MySQL mock test?

Each test has 30 multiple-choice questions to answer in 30 minutes, picked at random from 300 PHP and MySQL questions across three levels, so every attempt is different.

Which PHP and MySQL topics does the test cover?

The questions cover SQL Queries, Indexes, PHP Core, Security, Laravel, OOP, Transactions, Arrays, PDO, Scaling, Schema Design, Sessions. Your result shows how you did in each topic.

Which level should I choose?

Fresher if you are a student or have less than a year of experience, Intermediate for 1 to 5 years at work, and Experienced for 5 years or more.

Can employers see my PHP and MySQL score?

Only your best PHP and MySQL score, and only when it is 60% or more. It shows on the job applications you send on CoreHRx. Lower scores stay private.

Can I take the PHP and MySQL mock test again?

Yes, up to 10 tests a day. Each attempt picks questions you have not seen recently first.

All mock tests