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) . " is empty\r\n"; } else { echo var_dump($value) . " is not empty\r\n"; } }
Output for 4.3.0 - 7.1.0
int(0) is not empty float(0) is not empty string(1) "0" is not empty NULL is empty bool(false) is empty bool(true) is not empty int(1) is not empty float(1.1) is not empty float(0.1) is not empty string(7) "STARTED" is not empty