Created
April 24, 2012 10:16
-
-
Save lukearmstrong/2478611 to your computer and use it in GitHub Desktop.
empty()
This file contains hidden or 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 | |
$var = array(); | |
if (!empty($var)) { | |
// This is wrong? | |
} | |
if ($var) { | |
// This is better? | |
// Sure, you get an error if it is undefined, but the $var could still be anything that equates to true, which is almost anything. | |
} | |
// In either case you still don't know that it is an array. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment