Skip to content

Instantly share code, notes, and snippets.

@lukearmstrong
Created April 24, 2012 10:16
Show Gist options
  • Save lukearmstrong/2478611 to your computer and use it in GitHub Desktop.
Save lukearmstrong/2478611 to your computer and use it in GitHub Desktop.
empty()
<?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