Practice / php

PHP practice

Every PHP exercise, built from a topic you can open beside it.

69 exercises runs offline
php Quiz new Which operation keeps left-side values on duplicate keys and preserves non-sequential int… Use PHP's array transformation, filtering, reduction, merging, key, and sorting functions without losing keys or mutating the wrong value. beginner 1 min · from Array functions php Quiz new When does array_map preserve the input array keys? Use PHP's array transformation, filtering, reduction, merging, key, and sorting functions without losing keys or mutating the wrong value. intermediate 1 min · from Array functions php Predict the output new What does this program print? Use PHP's array transformation, filtering, reduction, merging, key, and sorting functions without losing keys or mutating the wrong value. beginner 2 min · from Array functions php Quiz new What is the first accumulator passed by array_reduce($values, $callback) when the initial… Use PHP's array transformation, filtering, reduction, merging, key, and sorting functions without losing keys or mutating the wrong value. intermediate 1 min · from Array functions php Review AI code new Review generated product feed Use PHP's array transformation, filtering, reduction, merging, key, and sorting functions without losing keys or mutating the wrong value. advanced 6 min · from Array functions php Spot the bug new Spot the bug in the filter callback Use PHP's array transformation, filtering, reduction, merging, key, and sorting functions without losing keys or mutating the wrong value. intermediate 4 min · from Array functions php Quiz new After $copy = $original, which later change can still be visible through both arrays? Understand PHP arrays as ordered maps, including key normalization, list shape, value semantics, references, and silent shape-changing mistakes. intermediate 1 min · from Arrays php Quiz new Which expression returns true when key email exists with value null? Understand PHP arrays as ordered maps, including key normalization, list shape, value semantics, references, and silent shape-changing mistakes. beginner 1 min · from Arrays php Predict the output new What does this program print? Understand PHP arrays as ordered maps, including key normalization, list shape, value semantics, references, and silent shape-changing mistakes. beginner 2 min · from Arrays php Predict the output new What JSON does this program print? Understand PHP arrays as ordered maps, including key normalization, list shape, value semantics, references, and silent shape-changing mistakes. beginner 2 min · from Arrays php Review AI code new Review generated catalog index Understand PHP arrays as ordered maps, including key normalization, list shape, value semantics, references, and silent shape-changing mistakes. advanced 6 min · from Arrays php Spot the bug new Spot the bug in the foreach reference Understand PHP arrays as ordered maps, including key normalization, list shape, value semantics, references, and silent shape-changing mistakes. intermediate 4 min · from Arrays php Quiz new What does an iterable parameter declaration guarantee? PHP runtime types, declarations, coercion, and strict mode, with boundary techniques that preserve both type and business meaning. beginner 1 min · from Data types php Predict the output new Which two type names are printed? PHP runtime types, declarations, coercion, and strict mode, with boundary techniques that preserve both type and business meaning. beginner 2 min · from Data types php Predict the output new What does this program print? PHP runtime types, declarations, coercion, and strict mode, with boundary techniques that preserve both type and business meaning. beginner 2 min · from Data types php Review AI code new Review generated order input mapper PHP runtime types, declarations, coercion, and strict mode, with boundary techniques that preserve both type and business meaning. advanced 6 min · from Data types php Spot the bug new Spot the bug in the quantity parser PHP runtime types, declarations, coercion, and strict mode, with boundary techniques that preserve both type and business meaning. beginner 4 min · from Data types php Quiz new A function is declared in a file that has strict_types=1, but a non-strict file calls it … PHP runtime types, declarations, coercion, and strict mode, with boundary techniques that preserve both type and business meaning. intermediate 1 min · from Data types php Quiz new A new enum case reaches a match expression that has no matching arm and no default. What … Model closed sets with PHP enums, including pure and backed enums, boundary parsing, methods, serialization, and safe evolution. intermediate 1 min · from Enums php Predict the output new Which three lines are printed? Model closed sets with PHP enums, including pure and backed enums, boundary parsing, methods, serialization, and safe evolution. intermediate 2 min · from Enums php Predict the output new What does this program print? Model closed sets with PHP enums, including pure and backed enums, boundary parsing, methods, serialization, and safe evolution. beginner 2 min · from Enums php Quiz new What is the default JSON behavior of a pure enum? Model closed sets with PHP enums, including pure and backed enums, boundary parsing, methods, serialization, and safe evolution. intermediate 1 min · from Enums php Review AI code new Review generated status parser Model closed sets with PHP enums, including pure and backed enums, boundary parsing, methods, serialization, and safe evolution. advanced 6 min · from Enums php Spot the bug new Spot the bug in the UnitEnum helper Model closed sets with PHP enums, including pure and backed enums, boundary parsing, methods, serialization, and safe evolution. intermediate 4 min · from Enums php Quiz new What must a custom error handler return when PHP default display or logging should still … Understand PHP diagnostic levels, custom handlers, ErrorException conversion, shutdown inspection, and production-safe reporting. beginner 1 min · from Error handling php Predict the output new Which class name does this program print? Understand PHP diagnostic levels, custom handlers, ErrorException conversion, shutdown inspection, and production-safe reporting. beginner 2 min · from Error handling php Predict the output new What does this program print? Understand PHP diagnostic levels, custom handlers, ErrorException conversion, shutdown inspection, and production-safe reporting. beginner 2 min · from Error handling php Quiz new Which production baseline preserves diagnostics without exposing them in HTTP responses? Understand PHP diagnostic levels, custom handlers, ErrorException conversion, shutdown inspection, and production-safe reporting. intermediate 1 min · from Error handling php Review AI code new Review generated endpoint boundary Understand PHP diagnostic levels, custom handlers, ErrorException conversion, shutdown inspection, and production-safe reporting. advanced 6 min · from Error handling php Spot the bug new Spot the bug in the warning handler Understand PHP diagnostic levels, custom handlers, ErrorException conversion, shutdown inspection, and production-safe reporting. intermediate 4 min · from Error handling php Predict the output new In what order are the three words printed? Understand how PHP throws, propagates, catches, and cleans up after exceptions, then design failure boundaries with types and exception chains. beginner 2 min · from Exceptions php Predict the output new Which line does this program print? Understand how PHP throws, propagates, catches, and cleans up after exceptions, then design failure boundaries with types and exception chains. beginner 2 min · from Exceptions php Quiz new Which expression wraps $error while preserving it as the programmatic cause? Understand how PHP throws, propagates, catches, and cleans up after exceptions, then design failure boundaries with types and exception chains. intermediate 1 min · from Exceptions php Review AI code new Review generated payment boundary Understand how PHP throws, propagates, catches, and cleans up after exceptions, then design failure boundaries with types and exception chains. advanced 6 min · from Exceptions php Spot the bug new Spot the bug in import cleanup Understand how PHP throws, propagates, catches, and cleans up after exceptions, then design failure boundaries with types and exception chains. intermediate 4 min · from Exceptions php Quiz new Which catch type can receive both a thrown RuntimeException and an engine TypeError? Understand how PHP throws, propagates, catches, and cleans up after exceptions, then design failure boundaries with types and exception chains. beginner 1 min · from Exceptions php Quiz new What does PHP operator precedence guarantee? Learn how PHP files execute, how expressions produce values, and how conditions, loops, and functions keep programs predictable. intermediate 1 min · from PHP fundamentals php Predict the output new Which label does this match expression print? Learn how PHP files execute, how expressions produce values, and how conditions, loops, and functions keep programs predictable. beginner 2 min · from PHP fundamentals php Predict the output new What two values does this program print? Learn how PHP files execute, how expressions produce values, and how conditions, loops, and functions keep programs predictable. beginner 2 min · from PHP fundamentals php Review AI code new Review generated order list renderer Learn how PHP files execute, how expressions produce values, and how conditions, loops, and functions keep programs predictable. advanced 6 min · from PHP fundamentals php Spot the bug new Spot the bug in the switch branch Learn how PHP files execute, how expressions produce values, and how conditions, loops, and functions keep programs predictable. beginner 4 min · from PHP fundamentals php Predict the output new Which two city names are printed? Understand PHP 8.3 magic-method triggers, safe dispatch, cloning, and serialization contracts without turning hooks into hidden interfaces. intermediate 2 min · from Magic methods php Predict the output new What does this program print? Understand PHP 8.3 magic-method triggers, safe dispatch, cloning, and serialization contracts without turning hooks into hidden interfaces. beginner 2 min · from Magic methods php Quiz new When does an external read call __get()? Understand PHP 8.3 magic-method triggers, safe dispatch, cloning, and serialization contracts without turning hooks into hidden interfaces. beginner 1 min · from Magic methods php Review AI code new Review generated order proxy Understand PHP 8.3 magic-method triggers, safe dispatch, cloning, and serialization contracts without turning hooks into hidden interfaces. advanced 6 min · from Magic methods php Quiz new A class defines both __serialize() and __sleep(). Which hook does serialize() use on PHP … Understand PHP 8.3 magic-method triggers, safe dispatch, cloning, and serialization contracts without turning hooks into hidden interfaces. intermediate 1 min · from Magic methods php Spot the bug new Spot the bug in proxy forwarding Understand PHP 8.3 magic-method triggers, safe dispatch, cloning, and serialization contracts without turning hooks into hidden interfaces. intermediate 4 min · from Magic methods php Quiz new A file imports App\Models\Invoice, then sets $class = "Invoice" and executes new $class()… PHP namespaces separate colliding declarations and connect code organization, import aliases, name resolution, and PSR-4 autoloading. intermediate 1 min · from Namespaces php Quiz new What does use Vendor\Mail\Client; do in a PHP file? PHP namespaces separate colliding declarations and connect code organization, import aliases, name resolution, and PSR-4 autoloading. beginner 1 min · from Namespaces php Predict the output new What does this program print? PHP namespaces separate colliding declarations and connect code organization, import aliases, name resolution, and PSR-4 autoloading. beginner 2 min · from Namespaces php Review AI code new Review generated exporter factory PHP namespaces separate colliding declarations and connect code organization, import aliases, name resolution, and PSR-4 autoloading. advanced 6 min · from Namespaces php Spot the bug new Spot the bug in the PSR-4 mapping PHP namespaces separate colliding declarations and connect code organization, import aliases, name resolution, and PSR-4 autoloading. intermediate 4 min · from Namespaces php Quiz new What does constructor property promotion guarantee by itself? Build clear contracts with PHP 8.3 classes, encapsulation, interfaces, inheritance, and composition while handling identity and initialization correctly. beginner 1 min · from Object-oriented programming php Quiz new Why would Checkout accept a ShippingPolicy interface in its constructor? Build clear contracts with PHP 8.3 classes, encapsulation, interfaces, inheritance, and composition while handling identity and initialization correctly. intermediate 1 min · from Object-oriented programming php Predict the output new What does this program print? Build clear contracts with PHP 8.3 classes, encapsulation, interfaces, inheritance, and composition while handling identity and initialization correctly. beginner 2 min · from Object-oriented programming php Review AI code new Review a generated wallet object Build clear contracts with PHP 8.3 classes, encapsulation, interfaces, inheritance, and composition while handling identity and initialization correctly. advanced 8 min · from Object-oriented programming php Spot the bug new Spot the bug in the Job subclass Build clear contracts with PHP 8.3 classes, encapsulation, interfaces, inheritance, and composition while handling identity and initialization correctly. intermediate 4 min · from Object-oriented programming php Quiz new What makes #[RequiresRole('admin')] enforce authorization in PHP? Use union types, named arguments, attributes, match, constructor property promotion, and the nullsafe operator without hiding migration risks. beginner 1 min · from PHP 8.0 features php Quiz new A public method changes its parameter from $includeTax to $withTax without changing posit… Use union types, named arguments, attributes, match, constructor property promotion, and the nullsafe operator without hiding migration risks. intermediate 1 min · from PHP 8.0 features php Predict the output new What four lines does this program print? Use union types, named arguments, attributes, match, constructor property promotion, and the nullsafe operator without hiding migration risks. beginner 2 min · from PHP 8.0 features php Quiz new When can a promoted property be read through $this inside its constructor? Use union types, named arguments, attributes, match, constructor property promotion, and the nullsafe operator without hiding migration risks. intermediate 1 min · from PHP 8.0 features php Review AI code new Review generated shipping quote Use union types, named arguments, attributes, match, constructor property promotion, and the nullsafe operator without hiding migration risks. advanced 6 min · from PHP 8.0 features php Spot the bug new Spot the bug in the optional chain Use union types, named arguments, attributes, match, constructor property promotion, and the nullsafe operator without hiding migration risks. intermediate 4 min · from PHP 8.0 features php Predict the output new What does this program print? Reuse behavior across PHP 8.3 classes with traits, resolve member conflicts explicitly, and keep contracts, dependencies, and state ownership clear. intermediate 2 min · from Traits php Review AI code new Review generated audit trait Reuse behavior across PHP 8.3 classes with traits, resolve member conflicts explicitly, and keep contracts, dependencies, and state ownership clear. advanced 6 min · from Traits php Spot the bug new Spot the bug in the trait alias Reuse behavior across PHP 8.3 classes with traits, resolve member conflicts explicitly, and keep contracts, dependencies, and state ownership clear. intermediate 4 min · from Traits php Quiz new Can insteadof resolve a same-named property declared by a trait and its consuming class? Reuse behavior across PHP 8.3 classes with traits, resolve member conflicts explicitly, and keep contracts, dependencies, and state ownership clear. intermediate 1 min · from Traits php Quiz new A service must accept any object that can produce a reference, whether or not it uses For… Reuse behavior across PHP 8.3 classes with traits, resolve member conflicts explicitly, and keep contracts, dependencies, and state ownership clear. beginner 1 min · from Traits php Quiz new On PHP 8.3, when does a child get static trait storage distinct from the parent shown in … Reuse behavior across PHP 8.3 classes with traits, resolve member conflicts explicitly, and keep contracts, dependencies, and state ownership clear. advanced 1 min · from Traits