<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<!--
    More playing with PHP! during recording for Week 9 Lecture 2

    by: Sharon Tuttle
    last modified: 2024-03-19

    you can run this using the URL:
    https://nrs-projects.humboldt.edu/~st10/s24cs328/328lect09-2/328lect09-2-play.php

    strict-validated as follows:
    *   used command-line on nrs-projects to run:

        php 328lect09-2-play.php > 328lect09-2-play.xhtml

    *   put the URL for 328lect09-2-play.xhtml into
        https://validator.w3.org/nu/ or https://html5.validator.nu/
-->

<head>
    <title> page title here </title>
    <meta charset="utf-8" />

    <?php 
        // turn error reporting on for this PHP document
        
        ini_set('display_errors', 1);
        error_reporting(E_ALL);
    ?>

    <link href="https://nrs-projects.humboldt.edu/~st10/styles/normalize.css"
          type="text/css" rel="stylesheet" />
</head>

<body>
    <h1> More Playing with PHP </h1>

    <?php       
        $a_variable = "something";
        $my_variable = 'abc'.$a_variable."def";
        $another_var = "abc $a_variable def";
        $yet_another = 'abc $a_variable def';
    ?>

    <p> $my_variable has the value: <?= $my_variable ?> </p>

    <p> $another_var has the value: <?= $another_var ?> </p>

    <p> $yet_another has the value: <?= $yet_another ?> </p>

    <?php
        $val1 = 0;
        $val2 = false;

        if ($val1 === $val2)
        {
        ?>
             <p> Both $val1 and $val2 are the same value and type! </p>
        <?php
        }
        elseif ($val1 == $val2)
        {
        ?>
             <p> $val1 and $val2 are the same value but different types! </p>
        <?php
        }
        else
        {
        ?>
            <p> $val1 and $val2 are NOT the same value and type! <br />
                $val1: <?= $val1 ?> </br />
                $val2: <?= $val2 ?> </p>
        <?php
        }
    ?>

    <p>
    <?php
        $count = 1;

        while ($count < 5)
        {
        ?>
            MOO! <?= $count ?>
            <?php
            $count++;
        }
    ?>
    </p>

    <p>
    <?php
        for ($i = 0; $i < 6; $i++) 
        {
        ?>
            BAAA! <?= $i ?>
        <?php
        }
    ?>
    </p>

    <p>
    <?php
        $my_first_array = [10, 20, 30];

        foreach ($my_first_array as $next_num)
        {
        ?>
            <?= $next_num ?>
        <?php
        }
    ?>
    </p>

    <?php
        $my_first_assoc_array = ["a" => 1, "b" => 2, "c" => 3];

        foreach ($my_first_assoc_array as $next_key => $next_val)
        {
        ?>
            <p> key: <?= $next_key ?> has value: <?= $next_val ?> </p>
        <?php
        }
    ?>
    
    <footer>
    <hr />
    <p>
        Validate by pasting .xhtml copy's URL into<br />
        <a href="https://validator.w3.org/nu">
            https://validator.w3.org/nu
        </a>
        or  
        <a href="https://html5.validator.nu/">
            https://html5.validator.nu/
        </a>
    </p>
    </footer>
</body>
</html>