Using Booleans | True or False


bool(false)

Does 2 = 4

bool(true)

Does 2 = 2



The code used for index.php is below:


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../styles.css">
    <title>Booleans: True or False</title>
</head>
<body>
    
    <h1 class="lesson-h1">Using Booleans | True or False</h1>

    <?php

        $number = 2;

        function equals_one($val){
            if($val === 1){
                return true;
            } else {
                return false;
            }
        }

        //Will run same as function above with less coding
        function equals_two($val){
            return $val === 2;
        }

        $result1 = equals_one($number);
        echo "<br>";
        $result2 = equals_two($number);

        echo "<p style='background-color: lightblue;'>Does 2 = 4 " . var_dump($result1) . "</p>";
        echo "<p style='background-color: lightblue;'>Does 2 = 2 " . var_dump($result2) . "</p>";

        echo "<hr>";
        include('../show_code.php');
        show_code('index.php');
    ?>

</body>
</html>