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 = sizeof($var); var_dump($result); if (count($var) > 0){ foreach ($var as $v) { echo $v; } } } echo teste('');
Output for git.master, git.master_jit, rfc.property-hooks
int(1) Fatal error: Uncaught TypeError: sizeof(): Argument #1 ($value) must be of type Countable|array, string given in /in/BEbSE:40 Stack trace: #0 /in/BEbSE(52): teste('') #1 {main} thrown in /in/BEbSE on line 40
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:
59.99 ms | 401 KiB | 8 Q