<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="../xml/codehelp.xsl"?>
<?xml-stylesheet href="../xml/codehelpxml.css" type="text/css" ?>
<!DOCTYPE CODEHELP SYSTEM "../xml/codehelp.dtd">
<CODEHELP>
   <BEGIN TITLE="Writing PHP - 2"/><NAVIGATE FILEBASE="first.php" FILELINK="1 - Learn PHP" WWW="1">1 - Learn PHP</NAVIGATE>
<NAVIGATE FILEBASE="third.php" FILELINK="3 - Headers and variables" WWW="1">3 - Headers and variables</NAVIGATE>
<NAVIGATE FILEBASE="form.php" FILELINK="4 - PHP forms" WWW="1">4 - PHP forms</NAVIGATE>
<NAVIGATE FILEBASE="errors.php" FILELINK="5 - Debugging PHP" WWW="1">5 - Debugging PHP</NAVIGATE>
<NAVIGATE FILEBASE="taint.php" FILELINK="6 - Tainted input data" WWW="1">6 - Tainted input data</NAVIGATE>
<NAVIGATE FILEBASE="files.php" FILELINK="7 - Reading / writing files" WWW="1">7 - Reading / writing files</NAVIGATE>
<NAVIGATE FILEBASE="functions.php" FILELINK="8 - Common PHP functions" WWW="1">8 - Common PHP functions</NAVIGATE>
<NAVIGATE FILEBASE="../cgi-bin/start.pl?item=WML" FILELINK="What is WML?" WWW="1">What is WML?</NAVIGATE>
<NAVIGATE FILEBASE="../cgi-bin/start.pl?item=XML" FILELINK="What is XML?" WWW="1">What is XML?</NAVIGATE>
<PAGE HEADING="Writing PHP - 2" SUBHEADING="PHP output" /><PARA><TEXT>With or without database access and graphics capability, PHP is still a useful language for modern web sites.
The spread of XML and WML is a nightmare for designers of conventional sites. After so much time dealing with multiple browsers
using the idea of cross-brower pages, there are suddenly two new formats that cannot be combined with HTML. The thought of writing
two or even three identical sites is enough of a problem, without considering learning XML and WML. XSLT can be used to export
xHTML - reducing duplication, but WML is not so easy. PHP solves these problems by allowing the designer to create one set of
PHP files that can output WML, XML, XHTML, DHTML, HTML and any future flavours of the base language, SGML. If it's a text based markup language then PHP can output it. With additional libraries, it can even
handle non-text output like PNG and JPEG graphics.</TEXT></PARA>
<PARA><TEXT>This set of PHP files demonstrate this capability. The PHP code creates variables for the links and the page content, including
titles and headings, then PHP code (identical in each page) formats the bare content in a manner suitable for WML, XML and HTML. In 
the case of the CodeHelp site, the HTML is v4 - DHTML using CSS. In fact it uses the same CSS stylesheets as the rest of the 
CodeHelp site. It could just as easily output HTML3 or a frame based site suitable for older browsers not capable of using CSS.</TEXT></PARA>
<PARA><TEXT>The PHP code looks for a WAP device using the HTTP headers, looks for XSLT by looking for Microsoft Internet Explorer 5
or later and uses HTML for every other case. Preset blocks of code are then set only if the browser matches and the content of the 
variables are inserted into the output. The actual code downloaded to the browser shows no sign of the PHP behind it. (The use of these
pages to demonstrate WML output is the reason why these pages are shorter than others on this site. WML has a strict limit on the total
file size of the downloaded WML code.)</TEXT></PARA>
</CODEHELP>