Skip to content

Instantly share code, notes, and snippets.

@Sstobo
Created November 7, 2017 17:38
Show Gist options
  • Save Sstobo/0f3b9d89836d2779d76f58e41f01684e to your computer and use it in GitHub Desktop.
Save Sstobo/0f3b9d89836d2779d76f58e41f01684e to your computer and use it in GitHub Desktop.
[PHP truthy falsey] #php
$my_var = false;
if ( isset( $my_var ) ) {
echo "It's set!";
} else {
echo "It's not set.";
}
The empty() function checks if the variable is an empty string, 0, NULL, or false.
$my_var = false;
if ( empty( $my_var ) ) {
echo "It's empty!";
} else {
echo "It's not empty.";
}
It will return false if the variable has a non-empty and non-zero value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment