Listing 9.8.1 XML Time ServiceFilename: time.php
// Figure out our time format. If none is
// provided, default to RFC 2822 format:
$format = isset($_GET['format']) ?
$_GET['format'] : 'r';
// Generate the date:
$dstr = date($format);
// Define that we are returning XML
// content & not to cache:
// Now output a valid XML file:
<?xml version="1.0" ?>
Think of the benefits of this technology even in this simple case. What if the original web page was a large dynamically generated web page? Instead of the entire page having to reload to update just one small part of it, a simple request can handle that.
This article is taken from the chapter titled, "Web Page Creation/XHTML/CSS", which is excerpted from the new book, PHP 5 in Practice, authored by Eli White III and Jonathan Eisenhamer. Copyright 2007 by Sams Publishing. ISBN 0672328887. Reprinted with permission by Pearson Education; All rights reserved. A complete Table of Contents is available online.