Last active
February 18, 2017 01:45
-
-
Save makoru-hikage/6f404f2133e1fa62ab004170b37c0f50 to your computer and use it in GitHub Desktop.
The correct use of switch case to test a variable's type. Correction for NullIsArray.php
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 (gettype($dummy['Alpha'])) { | |
case 'array' : | |
echo 'Alpha, according to this switch statement, is Array'; | |
break; | |
case 'double' : | |
case 'integer' : | |
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