2017-04-26 3 views
0

Der folgende Code gibt TRUE,FALSE,FALSE,FALSE, Ich verstehe nicht die richtige Antwort auf leere Arrays. Jemand hat eine Erklärung?PHP - Sind leere Arrays als null

$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,"); 
} 

Antwort

-1

Antwort hier: PHP behandelt NULL, falsch, 0, und die leere Zeichenkette als gleich, siehe hier Stackoverflow php is null or empty?

... und leere Arrays

sehr vorsichtig sein müssen, damit

Verwandte Themen