Booleantruefalseandthestrings & amp; quot; true & amp; quot; false & amp;
Booleans are used to represent the concepts of true and false. they are most often used for testing if a statement is true or false and they'll play a bigger role when we discuss logical expressions. note that there is a difference between boolean true/false and the strings "true"/"false ".
- Booleans and NULL
- /* Booleans are used to represent the concepts of true and false.
- They are most often used for testing if a statement is true or false and
- They'll play a bigger role when we discuss logical expressions.
- Note that there is a difference
- Boolean true/false and the strings "true"/"false ".
- */
- $ Bool1 = true;
- $ Bool2 = false;
- // When booleans are displayed, PHP will attempt to convert them into a string
- // You'll get either "1"/"0" or "1 leading /" instead of true/false
- ?>
- $ Bool1:
- $ Bool2:
- /* NULL is used to represent the concept of nothing or the state of being empty
- In the below example three variable have been set,
- Then boolean tests are saved Med and the results are output as a string
- */
- $ Var1 = 3;
- $ Var2 = "cat ";
- $ Var4 = NULL;
- // Isset tests whether a variable has been set
- // It returns true or false as a result of the test.
- ?>
- $ Var1 is set:
- $ Var2 is set:
- $ Var3 is set:
-
- $ Var1 is set:
- $ Var2 is set:
- $ Var3 is set:
-
- $ Var1 empty:
- $ Var4 empty:
|