Language playground

Modern PHP 8.4 language features live: property hooks, asymmetric visibility and new array functions - every tab shows the real, server-executed PHP code and an actually computed result, using your own input.

The `celsius` property's `set` hook runs on EVERY assignment, and silently clamps to absolute zero (-273.15 °C), never throwing. The `fahrenheit` property has no backing storage of its own: its value is always COMPUTED from celsius - set either one, the other follows automatically.

The PHP code that actually runs
final class Temperature
{
    public const float ABSOLUTE_ZERO_CELSIUS = -273.15;

    public float $celsius {
        set {
            // Csendben szorít, sosem dob kivételt
            $this->celsius = max(self::ABSOLUTE_ZERO_CELSIUS, $value);
        }
    }

    // Nincs saját tárolt mezője - mindig a celsius-ból számolt érték
    public float $fahrenheit {
        get => $this->celsius * 9 / 5 + 32;
        set {
            $this->celsius = ($value - 32) * 5 / 9;
        }
    }
}
Unit

Why do these new PHP 8.4 language features matter?

Property hooks used to require getter/setter methods to achieve the same behaviour ($obj->getCelsius() instead of $obj->celsius) - property hooks let you access a field like a plain property while validation or computation still runs behind the scenes, without duplicating code.

Asymmetric visibility solves the case where a property should be read-only from the outside but writable from within the class - previously this needed a separate private field plus a public getter method; in PHP 8.4 it fits in one line (public private(set) $balance).

array_find/array_any/array_all run natively in PHP 8.4, inside the language's own C implementation - previously the same logic required a foreach loop, or array_filter combined with extra logic, which was slower and more verbose.

None of these features add new capabilities as such: everything shown here was already possible in earlier PHP versions, just with more code and more room for bugs - the goal is cleaner, shorter, less error-prone code.