Created
November 7, 2017 17:38
-
-
Save Sstobo/0f3b9d89836d2779d76f58e41f01684e to your computer and use it in GitHub Desktop.
[PHP truthy falsey] #php
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
$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