2

The following code gives TRUE,FALSE,FALSE,FALSE, I dont understand the TRUE response on empty arrays. Someone has an explanation?

$results=array();
// Case 1 : Empty array
$myArray=array();
array_push($results, ($myArray==null));
array_push($results, ($myArray===null));
// Case 2 : Non Empty array
$myArray=array(1);
array_push($results,($myArray==null));
array_push($results,($myArray===null));
//
foreach ($results as $result) {
    if ($result) echo("TRUE,"); else echo ("FALSE,");
}
tit
  • 599
  • 3
  • 6
  • 25

1 Answers1

0

Response here : PHP treats NULL, false, 0, and the empty string as equal, see stackoverflow here php is null or empty?

... and empty arrays

Need to be very careful so

Community
  • 1
  • 1
tit
  • 599
  • 3
  • 6
  • 25