NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content

Quiz: PHP

PHP questions from real interviews as a quiz, with an explanation for every option.

25 questionsAll topicsPHP

Try it: 5 questions

Loading…

Sample questions

  1. What is the primary role of the Model in the MVC architecture?

    • Handle HTTP requests and select the appropriate view
    • Configure routes and manage navigation between pages
    • Build HTML pages and display data to the user
    • Manage the application's data and business logic
    Full answer
  2. How does separating a class according to SRP typically affect the risk of regressions when requirements change?

    • It has no effect: only test coverage affects regression risk
    • It increases the risk: every change requires modifying more classes
    • It reduces the risk: a change to one responsibility is less likely to affect unrelated parts
    • It eliminates the risk: a class with one responsibility cannot contain bugs
    Full answer
  3. How is a many-to-many relationship between two tables typically implemented in MySQL?

    • Create a junction table with foreign keys referencing both tables
    • Add a foreign key to the second table in the first table
    • Copy the data from both tables into a separate shared table
    • Add a column containing a list of IDs to each table
    Full answer
  4. What is a protocol in a computer network?

    • A physical channel that carries network signals
    • An address used to locate a device on a network
    • A program that stores network data on a server
    • A set of rules defining the format and order of data exchange
    Full answer
  5. Which three approaches can speed up searches on a string field in a database?

    • Create an index suited to the search condition.
    • Cache results of frequently repeated queries.
    • Split every string value into separate rows; this always speeds up searching.
    • Avoid applying functions to a field in WHERE when that prevents index use.
    • Add a FULLTEXT index to speed up every search using a %text% pattern.
    Full answer
  6. In software design, what does coupling mean, and what level is generally preferred?

    • The number of methods in a module; as few methods as possible are generally preferred.
    • How closely related the elements within a module are; low cohesion is generally preferred.
    • The degree to which modules depend on one another; low coupling is generally preferred.
    • The number of interfaces between modules; as many interfaces as possible are generally preferred.
    Full answer
  7. What typically allows a database to find a row quickly by its primary key value?

    • An index on the primary key column
    • A full table scan
    • Caching every row in the table
    • A relationship with foreign keys
    Full answer
  8. In MySQL, what is the main difference between EXPLAIN and EXPLAIN ANALYZE?

    • EXPLAIN ANALYZE runs the query only when an index is available; otherwise, it returns estimates.
    • Both commands run the query, but EXPLAIN ANALYZE also lists the indexes used.
    • EXPLAIN shows estimated plan details without running the query, while EXPLAIN ANALYZE runs it and reports actual metrics.
    • EXPLAIN reports actual metrics, while EXPLAIN ANALYZE only shows optimizer estimates.
    Full answer
  9. Which benefits does PDO provide when working with databases in PHP? Select all that apply.

    • Configurable error-handling modes
    • A common interface for working with different database systems
    • Automatic reconnection and retrying failed queries
    • Prepared statements that help protect against SQL injection
    • Automatic conversion of SQL queries to each database system’s dialect
    Full answer
  10. Which option best describes a unit test?

    • It automatically checks a small piece of code separately from the rest of the system.
    • It checks how fast an application performs under heavy load.
    • It manually checks an application by following a predefined scenario.
    • It checks how all the main parts of an application work together.
    Full answer