Make your web page more dynamic

This page demonstrates some easy little scripts in PHP. See a short description of how they work which I've written on The Horse's Mouth.

1. to show the current month and year on your page:
It is now May 2008

2. to include an image that steps through a cycle, showing each image in turn for 70 minutes:

Crickely Hill

3. To include the content of a text file (that can contain a message of the day that you can easily update):
This is the content of a sample "message of the day" file used in the Well House Consultant's "Early steps in PHP" demonstration. You can run the demonstration here, you can read all about it here and you can learn a whole lot more about PHP on our training courses which are described here.

4. To include the page's own URL:
This page is at http://www.wellho.net/demo/abc.php

5. To display the source code of a PHP page (be very careful of this one - I'm using it to show you how this page works but it does reveal your tricks - and any security holes in them - to your site visitors:
<html>
<head>
<title>Early steps in PHP</title>
</head>
<body bgcolor=#FFCCFF>
<h1>Make your web page more dynamic</h1>
This page demonstrates some easy little scripts in PHP.
See <a href=http://www.wellho.net/mouth/624_.html>a
short description of how they work</a> which I've written on
<a href=http://www.wellho.net/horse/>The Horse's Mouth</a>.
<br><br>
1. to show the current month and year on your page:<br>

It is now <?= date ("F Y"?>

<br><br>
2. to include an image that steps through a cycle, showing
each image in turn for 70 minutes:<center>

<?php $imagelist = array("klake","chill","swood");
#%% Some easy things to do with PHP
$textlist = array("Killingworth Lake","Crickely Hill",
    
"Swainswick Wood");
$picnumber floor(time()/60/70)%count($imagelist);
echo (
"<img src=$imagelist[$picnumber].jpg><br>");
echo (
"<b>$textlist[$picnumber]</b>"); ?>

</center><br>
3. To include the content of a text file (that can contain
a message of the day that you can easily update):<br>

<?php include("../../include/demo.txt"); ?>

<br><br>
4. To include the page's own URL:<br>
This page is at 

http://<?php
echo ($_SERVER[SERVER_NAME]);
echo (
$_SERVER[REQUEST_URI]); ?>

<br><br>
5. To display the source code of a PHP page (be very careful
of this one - I'm using it to show you how this page works
but it does reveal your tricks - and any security holes in 
them - to your site visitors:<br>

<?php /* highlight_file($_SERVER[SCRIPT_FILENAME]); */ ?>
<?php 
/* PREVIOUS LINE works for most people  - we wrap it as
follows since our demo pages are wrapped in a protective blanket */ 
?>
<?php highlight_file
("$_SERVER[DOCUMENT_ROOT]$_SERVER[REDIRECT_URL]"); ?>


<hr>
Page by Graham Ellis of Well House Consultants.<br>
</body>
</html>

Page by Graham Ellis of Well House Consultants.


Training sample © 2008, WELL HOUSE CONSULTANTS LTD
This is http://www.wellho.net/demo/abc.php
See source code here • More examples - same topic here
Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
Phone: +44 (0) 1225 708 225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net