Source of “minesweeper.php”
<?php // Emacs settings: -*- mode: Fundamental; tab-width: 4; -*-

////////////////////////////////////////////////////////////////////////////
//                                                                        //
// Minesweeper, implemented in JavaScript                                 //
//                                                                        //
// Copyright 1998-2007, Andrew D. Birrell                                 //
//                                                                        //
// PHP, including the stylesheet inline                                   //
//                                                                        //
// Usage:                                                                 //
//   $cols = 8;                                                           //
//   $rows = 8;                                                           //
//   $mines = 10;                                                         //
//   require("minesweeper.php");                                          //
//                                                                        //
////////////////////////////////////////////////////////////////////////////

if (!isset($cols) || !isset($rows) || !isset($mines)) {
    exit("Minesweeper.php: missing parameter(s)");
}

header("Content-Type: text/html; charset=UTF-8");

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
<!-- ----------------------------------------------------------------
     Copyright 1998-2009, Andrew D. Birrell.  See ./source.php
     ---------------------------------------------------------------- -->
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<SCRIPT TYPE="text/javascript" SRC="minesweeper.js"></SCRIPT>
<LINK HREF="../parts/home.css" REL=stylesheet>
<LINK HREF="minesweeper.css" REL=stylesheet>
<TITLE>Minesweeper in Javascript</TITLE>
</HEAD>
<BODY onload="init(<?php echo "$cols, " . ($cols*$rows) . ", $mines" ?>)">
<TABLE CLASS=sq ID=sqTable CELLSPACING=1 onmouseup="return false">
<TR><TD CLASS=score COLSPAN=<?php echo $cols?>>
  <DIV CLASS=counter ID=mines>&nbsp;</DIV>
  <DIV CLASS=counter ID=timer>&nbsp;</DIV>
  <TABLE class=smiley CELLSPACING=0><TR><TD CLASS=smiley
    onmousedown="return clickSmiley(event)"><IMG ID=smiley
    WIDTH=24 HEIGHT=24 SRC="erasing.gif" ALT=""></TD></TR></TABLE>
</TD></TR>
<?php
    for ($row = 0; $row < $rows; $row++) { ?>
<TR>
<?php
        for ($col = 0; $col < $cols; $col++) { ?>
<TD CLASS=sq ID="sq-<?php echo $row * $cols + $col ?>"
  onmousedown="return clickSq(event,<?php echo $row * $cols + $col ?>)"
  >&nbsp;</TD>
<?php
        } ?>
</TR>
<?php
}
?>
</TABLE>
<!-- End of script-generated HTML -->
End of listing