PHP Language Features

<!DOCTYPE html>
<html>
    <head>
        <title>First PHP Example</title>
    </head>
    <body>

    <h1>Our First Example</h1>

    <?php
      // Ask PHP to print all errors and warnings
      // This is very helpful when developing
      error_reporting(E_ALL);
      ini_set('display_errors', 1);
      
      // comments
      # comments
      /**
       * comments
       */

      /*
        comments
       */

      echo "Hello world!<br>\n";

      echo "Again!";

      $var = "5 apples";

      function context($var) {
        return "Variable: $var, type: " . gettype($var) . "<br>\n";
      }

      echo context($var); 

      $var += 64;
      echo context($var); 

      $var .= " apples";
      echo context($var); 

      $var = (int) $var;
      echo context($var);

      $var *= 5.1773467;
      echo context($var);

      $var = (int) $var;
      echo context($var);

      for ($i = 0; $i < 5; $i++) {
        $foo = 5;
      ?>
        <h2>Hi!</h2> <!-- don't do this! -->
      <?php
      }

      // Unset $i or else it will persist
      unset($i);
      echo "After the loop \$i = $i<br>";
      // $foo persists!
      echo "After the loop \$foo = $foo<br>";

      // Check whether $i is null (will be after unset())
      if (is_null($i)) echo "i was null";
    ?>

    </body>
</html>