I'm a long time Perl programmer and now want to learn PHP which, I understand, is pretty straight forward.
The following, untested, test page is to be accessed using 'http://www.domain.com/index.php?pagename'
<html>
<head><title>test page</title>
<!-- meta stuff -->
</head>
<body>
Top of page graphics and navigation<br>
<?php
// Get timestamp for the this user.
// $timestamp = (derived from an HTTP header maybe)
// $today = getdate($timestamp);
$today = getdate();
$month = $today['month'];
$mday = $today['mday'];
$year = $today['year'];
echo "$month $mday, $year";
?>
<p>Common body content<br>
<?php
// get data from file containing page specific content
$page = $_SERVER['QUERY_STRING'];
if ($page == 'about') { $filename = 'about.dat' }
elseif ($page == 'contact') { $filename = 'contact.dat' }
// etc.
// Can I do this or must I process the file line by line as shown below?
// echo file_get_contents($filename);
$fp=file($filename);
$x=0;
do {
echo $fp[$x];
$x++;
} while($fp[$x]);
?>
</p>
<p>Footer</p>
</body></html>
Comments on the above would be appreciated but what I really want is to insert the 'users' date. If I use the method shown
it inserts the 'server' date which will be incorrect for users in Australia and Europe.
In the past I've used a simple javascript 'document.write' but I want to minimize the use of javascript. So, how can I get the users timestamp.