You often see this code where there is a single variable as the conditional expression in an if
. What is this code doing? What makes the $some_variable
(conditional expression) true or false? What makes a single variable in a conditional expression falsey?
In this video, you will learn the intent of this if
conditional expression as well as what evaluates to false. This is known as checking the falsey state.
<?php | |
namespace KnowTheCode; | |
if ( $some_variable ) { | |
// do stuff | |
} |
Go check out this hands-on PHP coding lab to learn more deeply about “falsey state.”
Did you learn something new? Share your thoughts.