3v4l.org

run code in 300+ PHP versions simultaneously
<?php $value = 2; $count = new class($value) implements Countable { public function __construct($value) { $this->value = $value; } public function count() { return strlen($this->value); } }; echo count($count);
Output for 8.2.0 - 8.2.23, 8.3.0 - 8.3.11
Deprecated: Return type of Countable@anonymous::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/S28K7 on line 11 Deprecated: Creation of dynamic property Countable@anonymous::$value is deprecated in /in/S28K7 on line 8 1
Output for 8.1.0 - 8.1.29
Deprecated: Return type of Countable@anonymous::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/S28K7 on line 11 1
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
1

preferences:
79.39 ms | 409 KiB | 5 Q