Sunday, 6 December 2026 About Contact Write for Us Advertise Privacy

Developer interview practice

40 real-world questions with clear answers for WordPress, PHP, Laravel, React and Next.js developers. Take a practice interview and earn a certificate when you pass.

Choose your interview

Pass with 70% or more to unlock your certificate. Nothing you type is sent to us or saved.

Study guide: all questions and answers

WordPress Developer

1. What is the difference between an action and a filter in WordPress?

Answer: An action runs your code at a certain point, while a filter receives a value, changes it and must return it.

Both are hooks. Use add_action() to run code at a point such as init or wp_enqueue_scripts. Use add_filter() to modify data, such as the_content, and always return the (changed) value.

2. What is the correct way to load a stylesheet in a theme?

Answer: Call wp_enqueue_style() inside a function hooked to wp_enqueue_scripts.

Enqueuing lets WordPress manage dependencies, versions and duplicates, and lets plugins and child themes change or remove styles. Hook the function to wp_enqueue_scripts.

3. How do you protect a custom database query from SQL injection?

Answer: Use $wpdb->prepare() with placeholders.

$wpdb->prepare() safely inserts values using placeholders such as %s, %d and %f. Better still, use WP_Query or the $wpdb helper methods like insert() and update() where they fit.

4. What is a nonce in WordPress?

Answer: A time-limited token used to check that a request came from an intended action, which helps prevent CSRF.

Create one with wp_create_nonce() or wp_nonce_field() and check it with wp_verify_nonce() or check_admin_referer(). Nonces are not a replacement for capability checks such as current_user_can().

5. What is the right order for handling user data?

Answer: Validate and sanitize on input, then escape on output.

Sanitize functions such as sanitize_text_field() clean data before saving. Escape functions such as esc_html(), esc_attr() and esc_url() make data safe for the exact place where it is printed.

6. How should you change the main query on an archive page?

Answer: Use the pre_get_posts action and modify the query object.

pre_get_posts lets you alter the main query before it runs, for example only when is_main_query() and is_archive() are true. query_posts() replaces the main query and is discouraged.

7. On which hook should you register a custom post type?

Answer: init.

Call register_post_type() on init. Remember to flush rewrite rules once after changes, for example on plugin activation, and not on every page load.

8. What does the Transients API do?

Answer: Stores cached data with an expiry time.

set_transient(), get_transient() and delete_transient() cache expensive results, such as remote API calls. With a persistent object cache they live in memory, otherwise in the options table.

PHP Developer

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

Answer: === compares value and type, while == converts types before comparing.

Loose comparison can give surprising results because of type juggling. Prefer === unless you really want type conversion.

2. What does the null coalescing operator ?? do?

Answer: Returns the left value if it exists and is not null, otherwise the right value.

$name = $_GET['name'] ?? 'Guest'; does not raise a notice if the key is missing. Since PHP 7.4 you can also use ??= to assign a default.

3. How should passwords be stored?

Answer: Hash them with password_hash() and check them with password_verify().

password_hash() uses a strong, salted algorithm (bcrypt or Argon2) and password_needs_rehash() helps you upgrade later. MD5 and SHA-1 are not suitable for passwords.

4. Why use prepared statements with PDO?

Answer: They keep SQL code and data separate, which prevents SQL injection.

With placeholders, the database treats user input only as data. Also turn on exceptions with PDO::ATTR_ERRMODE and avoid building SQL with string concatenation.

5. What is the difference between include and require?

Answer: require stops the script with a fatal error if the file is missing, include only gives a warning.

Use require for files the application cannot work without. The *_once versions load a file only one time, but with Composer autoloading you rarely need them.

6. What is a trait used for?

Answer: To reuse methods across classes that do not share a parent.

Traits give horizontal code reuse because PHP supports only single inheritance. Use them carefully, as heavy use can hide dependencies.

7. Which magic method runs when an object is created?

Answer: __construct().

__construct() sets up the object. PHP 8 also allows constructor property promotion, for example public function __construct(private string $name) {}.

8. What does Composer do?

Answer: Manages project dependencies and provides autoloading.

Dependencies are listed in composer.json and locked in composer.lock. PSR-4 autoloading maps namespaces to folders so you do not need manual require statements.

Laravel Developer

1. What pattern does Eloquent ORM follow?

Answer: Active Record, where each model maps to a table row.

A model such as User corresponds to the users table, and an instance represents a row. It offers relationships, scopes, casts and events.

2. What are migrations for?

Answer: Version-controlling and sharing database schema changes.

Migrations describe schema changes in code. php artisan migrate applies them and migrate:rollback undoes the last batch, so every developer and server stays in sync.

3. What is middleware?

Answer: A layer that inspects or filters an HTTP request before or after it reaches the application.

Middleware handles tasks such as authentication, throttling and CORS. Register it on routes, groups or globally.

4. How do you fix the N+1 query problem?

Answer: Use eager loading with with().

Without eager loading, looping over posts and reading each author runs one extra query per post. Post::with('author')->get() loads the authors in one additional query.

5. What is the service container?

Answer: A tool that manages class dependencies and performs dependency injection.

Type-hint a class in a constructor or controller method and Laravel resolves it for you. Bind interfaces to implementations in a service provider.

6. How do you protect a model from mass assignment?

Answer: Define $fillable (allowed fields) or $guarded (blocked fields).

Without protection, a user could submit extra fields such as is_admin. Prefer an explicit $fillable list and validate input with Form Requests.

7. Why use queues?

Answer: To run slow tasks, such as sending email, in the background so requests stay fast.

Dispatch a job, and a worker started with php artisan queue:work processes it. Drivers include database, Redis and SQS, and failed jobs can be retried.

8. Which command creates a model together with its migration?

Answer: php artisan make:model Post -m.

The -m flag adds a migration. You can combine flags, for example -mfc for migration, factory and controller.

React Developer

1. What is the purpose of the virtual DOM?

Answer: React compares a lightweight copy of the UI to work out the smallest set of real DOM changes.

On each update React creates a new element tree, compares it with the previous one (reconciliation) and updates only the parts of the real DOM that changed.

2. What does useState return?

Answer: The current state value and a function to update it.

const [count, setCount] = useState(0). Calling setCount schedules a re-render with the new value. When the new value depends on the old one, use setCount(c => c + 1).

3. When does useEffect(() => {...}, []) run?

Answer: After the first render, and its cleanup runs when the component unmounts.

An empty dependency array means no reactive values are used. In development, React Strict Mode may run effects an extra time to help you find missing cleanup.

4. Why do list items need a key?

Answer: So React can identify which items changed, were added or removed.

Use a stable, unique id from your data. Avoid array indexes when items can be reordered, inserted or removed, as that can cause wrong state and extra work.

5. What is the difference between props and state?

Answer: Props are passed in by the parent and are read-only, while state is managed inside the component.

Data flows down from parent to child through props. When a child needs to change data, the parent passes down a function, or you lift the state up.

6. Why should you not change state directly?

Answer: React may not detect the change, so the UI may not update, and it can cause bugs.

Treat state as immutable. Create a new array or object, for example setItems([...items, newItem]) or setUser({ ...user, name }).

7. What does useMemo do?

Answer: Caches the result of a calculation until its dependencies change.

Use it for expensive calculations or to keep a stable object reference. Do not use it everywhere, because memoization has its own cost. Measure first.

8. What is a controlled component?

Answer: A form element whose value is driven by React state.

The input gets value={text} and onChange={e => setText(e.target.value)}, so React is the single source of truth for the field.

Next.js Developer

1. In the App Router, what is the default type of component?

Answer: A Server Component.

Server Components render on the server and send no component JavaScript to the browser, which keeps bundles smaller. They can fetch data directly.

2. Which file defines a dynamic blog post route in the App Router?

Answer: app/blog/[slug]/page.js.

Square brackets create a dynamic segment, and the value arrives through the params prop. Use [...slug] to catch all segments.

3. What does the "use client" directive do?

Answer: Marks a file and the components it imports as Client Components, needed for state, effects and event handlers.

Place it at the top of a file that uses hooks such as useState or browser APIs. Keep Client Components small and near the leaves of the tree.

4. What is Incremental Static Regeneration (ISR)?

Answer: Serving static pages that are refreshed in the background after a set time or on demand.

Set a revalidation time, or revalidate on demand with a tag or path. Visitors get fast cached pages while content stays reasonably fresh.

5. Why use the next/image component?

Answer: It optimizes images, serves suitable sizes, lazy-loads by default and helps prevent layout shift.

Always give width and height, or use fill, so the browser can reserve space. Use the priority option for the main above-the-fold image.

6. Where do you define a backend endpoint in the App Router?

Answer: In a route.js file using exported handlers such as GET and POST.

For example app/api/contact/route.js can export async function POST(request). Always validate input and never trust the client.

7. Which environment variables are available in the browser?

Answer: Only those whose names start with NEXT_PUBLIC_.

Anything with that prefix is inlined into the client bundle at build time, so never put secrets in it. Keep API keys in server-only variables.

8. What is middleware in Next.js used for?

Answer: Running code before a request is completed, for redirects, rewrites, headers or simple auth checks.

It lives in middleware.js at the project root and can use a matcher to limit which paths it runs on. Keep it light, because it runs on many requests.

The certificate shows that you completed a practice assessment on our website. It is not an accredited qualification or a job guarantee.

Press Enter for full results · Ctrl/⌘ + K to open anywhere