3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $data[] = 0; $data[] = 0.0; $data[] = '0'; $data[] = NULL; $data[] = false; $data[] = true; $data[] = 1; $data[] = 1.1; $data[] = 0.1; $data[] = 'STARTED'; foreach ($data as $value) { if (empty($value) && (string)$value !== "0") { echo var_dump($value) . ' <b>is empty</b><br>'; } else { echo var_dump($value) . ' <b>is not empty</b><br>'; } }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
int(0) <b>is not empty</b><br>float(0) <b>is not empty</b><br>string(1) "0" <b>is not empty</b><br>NULL <b>is empty</b><br>bool(false) <b>is empty</b><br>bool(true) <b>is not empty</b><br>int(1) <b>is not empty</b><br>float(1.1) <b>is not empty</b><br>float(0.1) <b>is not empty</b><br>string(7) "STARTED" <b>is not empty</b><br>