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.
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;
}
}
}