Last active
February 18, 2017 01:01
-
-
Save makoru-hikage/d3aadc400a1638c955e03bede678642b to your computer and use it in GitHub Desktop.
It seems that a `null` value is treated as an array()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dummy= [ | |
'Alpha' => null, | |
'Beta' => null, | |
'Charlie' => null | |
]; | |
switch ($dummy['Alpha']) { | |
case is_array($dummy['Alpha']) : | |
echo 'gettype($dummy[\'Alpha\']) = '.gettype($dummy['Alpha'])."<br>"; | |
echo 'is_array($dummy[\'Alpha\']) = '.is_array($dummy['Alpha'])."<br>"; | |
echo 'Alpha, according to this switch statement, is Array'; | |
break; | |
case is_numeric($dummy['Alpha']) : | |
echo 'gettype($dummy[\'Alpha\']) = '.gettype($dummy['Alpha'])."<br>"; | |
echo 'is_array($dummy[\'Alpha\']) = '.is_array($dummy['Alpha'])."<br>"; | |
echo 'Alpha, according to this switch statement, is Numeric'; | |
break; | |
default: | |
echo 'Alpha, according to this switch statement, is something else'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment