readyforhires

Intermediate PHP test (Intermediate)

30 questions · 35 minutes · Free

OOP, Composer, PDO and Laravel basics.

Take the Intermediate PHP test

What it covers

Interview format

Earn a certificate

The Intermediate PHP test is one of the 5 tests of the WordPress Developer: Intermediate learning path. Pass it and the other 4 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.

Sample learning path certificate for WordPress Developer: Intermediate, made out to “Your name” and marked SAMPLE
Pass with 70% or more to earn a verifiable certificate. This is a sample: yours carries your name, the date you earned it and its own verify code.

Sample questions

5 sample questions from the Intermediate PHP test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.

  1. In a Laravel project, where and how should you define a task that runs every day at midnight?

    1. The task schedule is defined in the app/Console/Kernel.php file using the schedule() method.
    2. The task schedule is set up using the Artisan command 'schedule:run'.
    3. The task schedule is handled automatically by Laravel without any configuration.
    4. The task schedule is configured in the config/schedule.php file.

    Answer: A. The task schedule is defined in the app/Console/Kernel.php file using the schedule() method.

    In Laravel, task scheduling is configured in the app/Console/Kernel.php file using the schedule() method. This method is used to define tasks that should be run at specific intervals. The other options refer to incorrect locations or methods for task scheduling in Laravel.

  2. Which method is the most effective way to prevent SQL injection when using PHP and MySQL?

    1. Storing user input in session variables
    2. Using raw SQL without any validation
    3. Concatenating user input directly into SQL queries
    4. PDO prepared statements

    Answer: D. PDO prepared statements

    PDO prepared statements are a secure way to execute SQL queries by separating SQL logic from data, preventing SQL injection attacks. Other options like using raw SQL or concatenating user input directly into queries are vulnerable to SQL injection.

  3. A Laravel developer is experiencing issues with a route group where the defined routes are not being grouped under the intended URL path. What is the most likely cause of this issue?

    1. The route group is using the incorrect HTTP method for the defined routes.
    2. The route group is not using a middleware correctly.
    3. The route group is not properly defined within the 'routes/web.php' file.
    4. The route group is missing the 'prefix' parameter in the 'Route::group' method.

    Answer: D. The route group is missing the 'prefix' parameter in the 'Route::group' method.

    In Laravel, when using route groups, it is essential to define the 'prefix' parameter to ensure that the routes are grouped under a specific URL path. If the 'prefix' is missing, the routes will not be properly grouped, and the intended functionality may not work as expected. The other options are either irrelevant or incorrect for the given scenario.

  4. What is the behavior of a method declared as final in a class?

    1. The method can be overridden in subclasses.
    2. The method can be used as a trait method.
    3. The method cannot be overridden in subclasses.
    4. The method can be declared as abstract.

    Answer: C. The method cannot be overridden in subclasses.

    When a method is declared as final in a class, it prevents any subclass from overriding that method. This is useful when you want to ensure that a specific implementation remains unchanged in all subclasses.

  5. In a Laravel project, a developer needs to retrieve the results of a PDO query as an associative array with column names as keys. Which fetch mode should they configure PDO to use?

    1. PDO::FETCH_OBJ
    2. PDO::FETCH_NUM
    3. PDO::FETCH_CLASS
    4. PDO::FETCH_ASSOC

    Answer: D. PDO::FETCH_ASSOC

    PDO::FETCH_ASSOC is the correct fetch mode to retrieve rows as associative arrays, where the keys are the column names. This is commonly used in projects for easier data handling. PDO::FETCH_OBJ returns objects, PDO::FETCH_NUM returns numeric indexes, and PDO::FETCH_CLASS is for mapping to a specific class.

Frequently asked questions

How many questions are in the Intermediate PHP test?
30 questions (18 multiple choice, 9 multi-answer, 3 predict-the-output), with 35 minutes to answer them.
What does the Intermediate PHP test cover?
Classes, interfaces and traits, Composer and autoloading, PDO and SQL injection, Error handling, Laravel basics.
Is the Intermediate PHP test free?
Yes. It is free to take with a readyforhires account.
What level is the Intermediate PHP test?
Intermediate, in Backend.

More Backend tests

Roles that test these skills

Companies that test these skills

All practice tests · All Backend tests

Last updated