| Newsgroups |
php.notes |
| Message-ID |
<[email protected]> |
// 1) Define your cases with descriptive keys
$testCases = [
'empty_string_single' => '',
'empty_string_double' => "",
'null_value' => null,
'empty_array' => [],
'false_bool' => false,
'uppercase_NULL' => NULL,
'string_zero' => '0',
'int_zero' => 0,
];
// 2) Start HTML table
echo '<table border="1" cellpadding="4" cellspacing="0">';
echo '<tr>
<th>Case</th>
<th>Raw Value</th>
<th>Type</th>
<th>empty()?</th>
</tr>';
// 3) Iterate and report
foreach ($testCases as $label => $value) {
$raw = var_export($value, true);
$type = gettype($value);
$result = empty($value) ? 'true' : 'false';
echo "<tr>
<td>{$label}</td>
<td><code>{$raw}</code></td>
<td>{$type}</td>
<td>{$result}</td>
</tr>";
}
echo '</table>';
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 2001:861:3483:a1f0:e9f2:c7fb:7f14:64d)
----
Manual Page -- https://php.net/manual/en/function.empty.php
Edit -- https://main.php.net/note/edit/130434
Del: integrated -- https://main.php.net/note/delete/130434/integrated
Del: useless -- https://main.php.net/note/delete/130434/useless
Del: bad code -- https://main.php.net/note/delete/130434/bad+code
Del: spam -- https://main.php.net/note/delete/130434/spam
Del: non-english -- https://main.php.net/note/delete/130434/non-english
Del: in docs -- https://main.php.net/note/delete/130434/in+docs
Del: other reasons-- https://main.php.net/note/delete/130434
Reject -- https://main.php.net/note/reject/130434
Search -- https://main.php.net/manage/user-notes.php