3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php echo '<table border="1">'; echo '<tr><th>Value of variable ($var)</th><th>isset($var)</th><th>empty($var)</th><th>is_null($var)</th></tr>'; $var = ''; echo '<tr><td>"" (an empty string)</td><td>'; var_dump(isset($var)); echo '</td><td>'; var_dump(empty($var)); echo '</td><td>'; var_dump(is_null($var)); echo '</td></tr>'; $var = ' '; echo '<tr><td>" " (space)</td><td>'; var_dump(isset($var)); echo '</td><td>'; var_dump(empty($var)); echo '</td><td>'; var_dump(is_null($var)); echo '</td></tr>'; $var = FALSE; echo '<tr><td>FALSE</td><td>'; var_dump(isset($var)); echo '</td><td>'; var_dump(empty($var)); echo '</td><td>'; var_dump(is_null($var)); echo '</td></tr>'; $var = TRUE; echo '<tr><td>TRUE</td><td>'; var_dump(isset($var)); echo '</td><td>'; var_dump(empty($var)); echo '</td><td>'; var_dump(is_null($var)); echo '</td></tr>'; $var = array(); echo '<tr><td>array() (an empty array)</td><td>'; var_dump(isset($var)); echo '</td><td>'; var_dump(empty($var)); echo '</td><td>'; var_dump(is_null($var)); echo '</td></tr>'; $var = NULL; echo '<tr><td>NULL</td><td>'; var_dump(isset($var)); echo '</td><td>'; var_dump(empty($var)); echo '</td><td>'; var_dump(is_null($var)); echo '</td></tr>'; $var = '0'; echo '<tr><td>"0" (0 as a string)</td><td>'; var_dump(isset($var)); echo '</td><td>'; var_dump(empty($var)); echo '</td><td>'; var_dump(is_null($var)); echo '</td></tr>'; $var = 0; echo '<tr><td>0 (0 as an integer)</td><td>'; var_dump(isset($var)); echo '</td><td>'; var_dump(empty($var)); echo '</td><td>'; var_dump(is_null($var)); echo '</td></tr>'; $var = 0.0; echo '<tr><td>0.0 (0 as a float)</td><td>'; var_dump(isset($var)); echo '</td><td>'; var_dump(empty($var)); echo '</td><td>'; var_dump(is_null($var)); echo '</td></tr>'; unset($var); // doing this just as a precaution, to make sure $var is actually not defined. $var; echo '<tr><td>var $var; (a variable declared, but without a value)</td><td>'; var_dump(isset($var)); echo '</td><td>'; var_dump(empty($var)); echo '</td><td>'; var_dump(is_null($var)); echo '</td></tr>'; $var = '\0'; echo '<tr><td>NULL byte ("\ 0")</td><td>'; var_dump(isset($var)); echo '</td><td>'; var_dump(empty($var)); echo '</td><td>'; var_dump(is_null($var)); echo '</td></tr>'; echo '</table>';
Output for 5.1.0 - 5.6.28, 7.0.0 - 7.1.0
<table border="1"><tr><th>Value of variable ($var)</th><th>isset($var)</th><th>empty($var)</th><th>is_null($var)</th></tr><tr><td>"" (an empty string)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>" " (space)</td><td>bool(true) </td><td>bool(false) </td><td>bool(false) </td></tr><tr><td>FALSE</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>TRUE</td><td>bool(true) </td><td>bool(false) </td><td>bool(false) </td></tr><tr><td>array() (an empty array)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>NULL</td><td>bool(false) </td><td>bool(true) </td><td>bool(true) </td></tr><tr><td>"0" (0 as a string)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>0 (0 as an integer)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>0.0 (0 as a float)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>var $var; (a variable declared, but without a value)</td><td>bool(false) </td><td>bool(true) </td><td> Notice: Undefined variable: var in /in/QWKXE on line 92 bool(true) </td></tr><tr><td>NULL byte ("\ 0")</td><td>bool(true) </td><td>bool(false) </td><td>bool(false) </td></tr></table>
Output for hhvm-3.12.0
<table border="1"><tr><th>Value of variable ($var)</th><th>isset($var)</th><th>empty($var)</th><th>is_null($var)</th></tr><tr><td>"" (an empty string)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>" " (space)</td><td>bool(true) </td><td>bool(false) </td><td>bool(false) </td></tr><tr><td>FALSE</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>TRUE</td><td>bool(true) </td><td>bool(false) </td><td>bool(false) </td></tr><tr><td>array() (an empty array)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>NULL</td><td>bool(false) </td><td>bool(true) </td><td>bool(true) </td></tr><tr><td>"0" (0 as a string)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>0 (0 as an integer)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>0.0 (0 as a float)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr> Notice: Undefined variable: var in /in/QWKXE on line -1 <tr><td>var $var; (a variable declared, but without a value)</td><td>bool(false) </td><td>bool(true) </td><td> Notice: Undefined variable: var in /in/QWKXE on line -1 bool(true) </td></tr><tr><td>NULL byte ("\ 0")</td><td>bool(true) </td><td>bool(false) </td><td>bool(false) </td></tr></table>
Output for 5.0.4 - 5.0.5, hhvm-3.10.0
<table border="1"><tr><th>Value of variable ($var)</th><th>isset($var)</th><th>empty($var)</th><th>is_null($var)</th></tr><tr><td>"" (an empty string)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>" " (space)</td><td>bool(true) </td><td>bool(false) </td><td>bool(false) </td></tr><tr><td>FALSE</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>TRUE</td><td>bool(true) </td><td>bool(false) </td><td>bool(false) </td></tr><tr><td>array() (an empty array)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>NULL</td><td>bool(false) </td><td>bool(true) </td><td>bool(true) </td></tr><tr><td>"0" (0 as a string)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>0 (0 as an integer)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>0.0 (0 as a float)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr> Notice: Undefined variable: var in /in/QWKXE on line 86 <tr><td>var $var; (a variable declared, but without a value)</td><td>bool(false) </td><td>bool(true) </td><td> Notice: Undefined variable: var in /in/QWKXE on line 92 bool(true) </td></tr><tr><td>NULL byte ("\ 0")</td><td>bool(true) </td><td>bool(false) </td><td>bool(false) </td></tr></table>
Output for 4.3.0 - 5.0.3
<table border="1"><tr><th>Value of variable ($var)</th><th>isset($var)</th><th>empty($var)</th><th>is_null($var)</th></tr><tr><td>"" (an empty string)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>" " (space)</td><td>bool(true) </td><td>bool(false) </td><td>bool(false) </td></tr><tr><td>FALSE</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>TRUE</td><td>bool(true) </td><td>bool(false) </td><td>bool(false) </td></tr><tr><td>array() (an empty array)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>NULL</td><td>bool(false) </td><td>bool(true) </td><td>bool(true) </td></tr><tr><td>"0" (0 as a string)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>0 (0 as an integer)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr><tr><td>0.0 (0 as a float)</td><td>bool(true) </td><td>bool(true) </td><td>bool(false) </td></tr> Notice: Undefined variable: var in /in/QWKXE on line 86 <tr><td>var $var; (a variable declared, but without a value)</td><td>bool(false) </td><td>bool(true) </td><td> Notice: Undefined variable: var in /in/QWKXE on line 92 bool(true) </td></tr><tr><td>NULL byte ("\ 0")</td><td>bool(true) </td><td>bool(false) </td><td>bool(false) </td></tr></table>