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

<!--
    quick demo of PHP's JSON extension (as an example of
    JSON tools available in PHP)

    can run this from the URL:
    https://nrs-projects.humboldt.edu/~st10/s25cs328/328lect15-1/php-json-demo.php

    by: Sharon Tuttle
    last modified: 2025-05-06
-->

<head>  
    <title> PHP's JSON extension demo </title>
    <meta charset="utf-8" />

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

<body> 
    <h1> PHP's JSON extension demo </h1>

    <?php
    $myJSONString = file_get_contents("json-response-data.json");

    $phpVersion1 = json_decode($myJSONString);
    $phpVersion2 = json_decode($myJSONString, true);
    ?>

    <p> Trying out PHP's JSON extension a little </p>
    <ul>
        <li> <code>$phpVersion1->firstName is: [<?= $phpVersion1->firstName ?>] </code></li>
        <li> <code>$phpVersion1->{"age"} is: [<?= $phpVersion1->{"age"} ?>] </code></li> 

        <li> <code>$phpVersion2["firstName"] is: [<?= $phpVersion2["firstName"] ?>] </code></li>
        <li> <code>$phpVersion2["age"] is: [<?= $phpVersion2["age"] ?>] </code></li>
    </ul> 

    <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>