Voting

: three plus four?
(Example: nine)

The Note You're Voting On

Lukas
3 years ago
<?php

// Difference of empty() vs. isset()

$testCase = array(
1 => '',
2 => ' ',
3 => null,
4 => array(),
5 => false,
6 => true,
7 => '0',
8 => 0,
);

foreach (
$testCase as $k => $v) {
echo
"<br> $k => " . strval($v) . " " . (empty($v) ? "is empty" : "is not empty") . " / " . (isset($v) ? "is set" : "is not set");
}

/*
RESULT:
1 => is empty / is set
2 => is not empty / is set
3 => is empty / is not set
4 => Array is empty / is set
5 => is empty / is set
6 => 1 is not empty / is set
7 => 0 is empty / is set
8 => 0 is empty / is set
*/

<< Back to user notes page

To Top