<?php
  $level = $score = $time = 0;
?>
<?php
  $month = "March";

  if ($month == "March") echo "It's springtime";
?>
<?php
  $a = "1000";
  $b = "+1000";

  if ($a == $b)  echo "1";
  if ($a === $b) echo "2";
?>
<?php
  $a = "1000";
  $b = "+1000";

  if ($a != $b)  echo "1";
  if ($a !== $b) echo "2";
?>
<?php
  $a = 2; $b = 3;
  if ($a > $b)  echo "$a is greater than $b<br>";
  if ($a < $b)  echo "$a is less than $b<br>";
  if ($a >= $b) echo "$a is greater than or equal to $b<br>";
  if ($a <= $b) echo "$a is less than or equal to $b<br>";
?>
<?php
  $a = 1; $b = 0;

  echo ($a AND $b) . "<br>";
  echo ($a or $b)  . "<br>";
  echo ($a XOR $b) . "<br>";
  echo !$a         . "<br>";
?>
<?php
  if ($finished == 1 or getnext() == 1) exit;
?>
<?php
  $gn = getnext();

  if ($finished == 1 or $gn == 1) exit;
?>
<?php
  if ($bank_balance < 100)
  {
    $money         = 1000;
    $bank_balance += $money;
  }
?>
<?php
  if ($bank_balance < 100)
  {
    $money         = 1000;
    $bank_balance += $money;
  }
  else
  {
    $savings      += 50;
    $bank_balance -= 50;
  }
?>
<?php
  if ($bank_balance < 100)
  {
      $money         = 1000;
      $bank_balance += $money;
  }
  elseif ($bank_balance > 200)
  {
      $savings      += 100;
      $bank_balance -= 100;
  }
  else
  {
      $savings      += 50;
      $bank_balance -= 50;
  }
?>
<?php
  $page = "test";

  if     ($page == "Home")  echo "You selected Home";
  elseif ($page == "About") echo "You selected About";
  elseif ($page == "News")  echo "You selected News";
  elseif ($page == "Login") echo "You selected Login";
  elseif ($page == "Links") echo "You selected Links";
  else                      echo "Unrecognized selection";
?>
<?php
  switch ($page)
  {
      case "Home":  echo "You selected Home";
          break;
      case "About": echo "You selected About";
          break;
      case "News":  echo "You selected News";
          break;
      case "Login": echo "You selected Login";
          break;
      case "Links": echo "You selected Links";
          break;
  }
?>
<?php
switch ($page)
{
    case "Home":
        echo "You selected Home";
        break;
    case "About":
        echo "You selected About";
        break;
    case "News":
        echo "You selected News";
        break;
    case "Login":
        echo "You selected Login";
        break;
    case "Links":
        echo "You selected Links";
        break;
    default:
        echo "Unrecognized selection";
        break;
}
?>
<?php
  switch ($page):
      case "Home":
          echo "You selected Home";
          break;
  
      // etc...
  
      case "Links":
          echo "You selected Links";
          break;
  endswitch;
?>
<?php
  echo $fuel <= 1 ? "Fill tank now" : "There's enough fuel";
?>
<?php
  $enough = $fuel <= 1 ? FALSE : TRUE;
?>
<?php
  $fuel = 10;

  while ($fuel > 1)
  {
    // Keep driving ?    echo "There's enough fuel";
  }
?>
<?php
  $count = 1;

  while ($count <= 12)
  {
    echo "$count times 12 is " . $count * 12 . "<br>";
    ++$count;
  }
?>
<?php
  $count = 0;

  while (++$count <= 12)
    echo "$count times 12 is " . $count * 12 . "<br>";
?>
<?php
  $count = 1;

  do
    echo "$count times 12 is " . $count * 12 . "<br>";
  while (++$count <= 12);
?>
<?php
  $count = 1;
  
  do {
    echo "$count times 12 is " . $count * 12;
    echo "<br>";
  } while (++$count <= 12);
?>
<?php
  for ($count = 1 ; $count <= 12 ; ++$count)
    echo "$count times 12 is " . $count * 12 . "<br>";
?>
<?php
  for ($count = 1 ; $count <= 12 ; ++$count)
  {
    echo "$count times 12 is " . $count * 12;
    echo "<br>";
  }
?>
<?php
  $fp = fopen("text.txt", 'wb');

  for ($j = 0 ; $j < 100 ; ++$j)
  {
    $written = fwrite($fp, "data");

    if ($written == FALSE) break;
  }

  fclose($fp);
?>
<?php
  $j = 10;

  while ($j > -10)
  {
    $j--;

    if ($j == 0) continue;

    echo (10 / $j) . "<br>";
  }
?>
<?php
  $a = 56;
  $b = 12;
  $c = $a / $b;

  echo $c;
?>
<?php
  echo "a: [" . (20 > 9) . "]<br>";
  echo "b: [" . (5 == 6) . "]<br>";
  echo "c: [" . (1 == 0) . "]<br>";
  echo "d: [" . (1 == 1) . "]<br>";
?>
<?php // test2.php
  echo "a: [" . TRUE  . "]<br>";
  echo "b: [" . FALSE . "]<br>";
?>
<?php
  $myname = "Brian";
  $myage  = 37;

  echo "a: " . 73      . "<br>"; // Numeric literal
  echo "b: " . "Hello" . "<br>"; // String literal
  echo "c: " . FALSE   . "<br>"; // Constant literal
  echo "d: " . $myname . "<br>"; // String variable
  echo "e: " . $myage  . "<br>"; // Numeric variable
?>
<?php
  $day_number       = 340;                // Assignment by Value
  $days_to_new_year = 366 - $day_number;  // Assignment by Expression

  if ($days_to_new_year < 30)             // Condition
  {
    echo "Not long now till new year";    // Statement
  }
?>