3v4l.org

run code in 500+ PHP versions simultaneously
<?php final class DemoFile { public static function doCount($vars) { if (count($vars) > 0) { foreach ($vars as $key => $val) { echo "hello"; } } } } DemoFile::doCount(new stdClass());
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, stdClass given in /in/eGBHn:7 Stack trace: #0 /in/eGBHn(15): DemoFile::doCount(Object(stdClass)) #1 {main} thrown in /in/eGBHn on line 7
Process exited with code 255.
Output for 8.0.1 - 8.0.9
Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, stdClass given in /in/eGBHn:7 Stack trace: #0 /in/eGBHn(15): DemoFile::doCount(Object(stdClass)) #1 {main} thrown in /in/eGBHn on line 7
Process exited with code 255.

preferences:
81.53 ms | 1138 KiB | 5 Q