3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $str = trim('-1'); echo $str . "\n"; if ($str) { echo "option 1: not empty\n"; } if (strlen($str)) { echo "option 2: not empty\n"; } if (!empty($str)) { echo "option 3: not empty\n"; } if ($str !== '') { echo "option 4: not empty\n"; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
-1 option 1: not empty option 2: not empty option 3: not empty option 4: not empty