basic.php
<?php
/**
* A comment: put here some info
*
* @version 0.1
* @author me
* @license modify freely
*/
// This is a variable defined by me
$title = "A basic PHP example";
// Print html header
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"";
echo " \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><title>".$title."</title></head>";
echo "<body>";
?>
<!-- A php script region is a processing instruction -->
<h1><?php echo $title; ?></h1>
<p>
This is a transformation of page "
<?php echo basename($_SERVER['PHP_SELF']); ?>
"
done at <?php echo date('H:i - d M Y'); ?>
</p>
<p>
You are connecting from
<?php echo gethostbyaddr($_SERVER['REMOTE_ADDR']); ?>
</p>
<?php
echo "<p>An iteration example:";
$i = 0;
while ( $i < 10 ) echo " i= ".++$i;
echo "</p>";
?>
<!-- Outside scripts you can put hard coded html -->
</body></html>
Recommended tools:
- XAMPP: an handy cross platform all-in-one servers installer
- Notepad++ or PSPad: edit PHP files
- Firefox: render standard HTML files