3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $var = ''; $res = count($var); var_dump($res); if (count($var) > 0) { echo "yeah"; }else { echo "no"; } echo "\n\n"; $var = null; $res = count($var); var_dump($res); if (count($var) > 0) { echo "yeah"; }else { echo "no"; }
based on M4ZNN
Output for 7.2.0
Warning: count(): Parameter must be an array or an object that implements Countable in /in/7AtrU on line 5 int(1) Warning: count(): Parameter must be an array or an object that implements Countable in /in/7AtrU on line 8 yeah Warning: count(): Parameter must be an array or an object that implements Countable in /in/7AtrU on line 18 int(0) Warning: count(): Parameter must be an array or an object that implements Countable in /in/7AtrU on line 21 no
Output for 5.3.19 - 7.1.10
int(1) yeah int(0) no