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

<!--
    playing with array_key_exists and isset
    
    by: Sharon Tuttle 
    last modified: 2016-03-06
-->

<head>  
    <title> array_key_exists vs. isset </title>
    <meta charset="utf-8" />

    <link 
        href="http://users.humboldt.edu/smtuttle/styles/normalize.css" 
        type="text/css" rel="stylesheet" />
    <link href="ckbox-play.css" type="text/css" 
          rel="stylesheet" />
</head> 

<body> 

    <h1> playing with array_key_exists and isset </h1>

    <?php
        $conclusion = "";

        if (! array_key_exists("bike", $_GET) )
        {
            $conclusion = 'bike was NOT an index in $_GET';
        }

        elseif (! isset($_GET["bike"]) )
        {
            $conclusion = 'bike IS an index in $_GET, BUT '.
                          'is not set';
        }

        else
        {
            $conclusion = 'bike IS an index in $_GET, and '.
                          'IS set: ['.
                          htmlspecialchars($_GET["bike"]).
                          ']';
        }
    ?>

    <p> <?= $conclusion ?> </p>

    <p> what IS in $_GET right now? </p>

    <ul>
    
    <?php
        foreach ($_GET as $next_form_value)
        {
        ?>

            <li> next value in $_GET is:
                 <?= htmlspecialchars($next_form_value) ?>
                 </li>
        <?php
        }
        ?>

    </ul>

    <h2> oh, you want to see GET_$'s keys, also? </h2>

    <pre>

        <?php
            /* BEWARE! NOT SANITIZED! */

            print_r($_GET);
        ?>

    </pre>

    <!-- refactoring based on M. Lemos comment on 2016-03-02 -->

    <?php
        require_once("328footer-better.html");
    ?>

</body>
</html>