3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CountHelper { public static function count_if_you_can($var) { if (is_array($var)) { return count($var); } elseif (is_object($var)) { if ($var instanceof Countable) { return count($var); } else { return 1; } } elseif ($var === NULL) { return 0; } else { return 1; } } } function teste($var) { $result = CountHelper::count_if_you_can($var); var_dump($result); $result = count($var); var_dump($result); foreach ($var as $v) { echo $v; } } echo teste(123);
Output for git.master, git.master_jit, rfc.property-hooks
int(1) Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, int given in /in/gpCh9:38 Stack trace: #0 /in/gpCh9(47): teste(123) #1 {main} thrown in /in/gpCh9 on line 38
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
77.93 ms | 401 KiB | 8 Q