PHP
  Home arrow PHP arrow Page 3 - WAP-Enabling a Website with PHP3
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

WAP-Enabling a Website with PHP3
By: Mike Banahan
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 21
    2000-06-12

    Table of Contents:
  • WAP-Enabling a Website with PHP3
  • How it Works
  • Switching to WML
  • Conclusions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    WAP-Enabling a Website with PHP3 - Switching to WML


    (Page 3 of 4 )

    After we got the HTML site going, the next task was to WAP it up. The first concern was how much we would have to hack php3 to tell it not to emit a first line that says


    Content-type: text/html

    Although I couldn't find it documented anywhere, I found to my deep and abiding joy that if you use the php3 header() function to output a different content-type header, that suppresses the default. Bingo! Every WML card deck now includes this php fragment at the top:


    <? header("Content-type: text/vnd.wap.wml"); echo "<?xml version=\"1.0\"?>\n"; echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"" . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">\n"; ?>
    and that deals with all the usual crud you have to cough out to get started with WAP. From there on it was plain sailing. It took six hours to a) learn enough WML to get something done and b) implement it. I used Steve Mann's book "Programming Applications with the Wireless Application Protocol" (Wiley, ISBN 0-471-32754-9) as my reference, plus a few downloaded tutorials from places like Waptastic for backup. I wouldn't recommend any of them. Considering how restricted the WML language is, you would have thought it wouldn't take much explaining, but I have yet to see a decent tutorial on it. Maybe I am just too dim to pick it up easily. That might also account for how limited our current WAP version of the site is.

    Of course you can't rely on WML being correct without testing it. If there is a WML weblint-alike, I'd like to find it, but haven't looked hard enough yet. It would be a big help to ensure that the WML is well-formed on the way out. You also have to check that your WAP site `works', to the degree that you can make anything work through such a limited medium. There are a number of WAP phone simulators around. There is a web-based one at Gelon as well as others from phone.com and the marvellously named Slob-Trot in Finland. Sadly both the latter two only run under Windows so far as I can tell, but vmware came to the rescue. Or, at least it did for the Slob Trot browser, the phone.com version ran but didn't paint any images on the screen. I later found a native Windows machine and it seemed OK on that.

    Using the simulators to test the WML allowed the php3 templates to be written very quickly. Here is the full `place' template:


    <? require("stdwaphdr.tpl"); require('stdplace.tpl'); ?> <? $votepics = array("xx", "x", "+", "++", "+++"); ?> <card title="Search results" id="first"> <p> <?htmTplacetypename();?>(s) near <? htmT("placesearch"); ?><br/> <? if(isset($places)): ?> <? $placelist = new PlaceList; $placelist->import($places); $placelist->reset(); $count = 1; while($place = $placelist->next()): ?> <? echo htmlspecialchars("\"$place->name\", " . $place->county_address()); ?> <? printf("(%.2fm) ", ($place->distance_km()*100/1.6)/100); ?><br/> <? if(isset($Objects[$place->unique_id . "votes"])){ $arrayref = $Objects[$place->unique_id. "votes"]; // echo "Scores:"; $first = 1; while(list($key, $value) = each($arrayref)){ $idx = $value - 1; if($idx < 0) continue; $vname = $Objects["voteranktoshortnames"][$key]; if ($first) { $first = 0; } else { echo ", "; } if (($idx < sizeof($votepics)) && ($idx >= 0)) { echo "$vname $votepics[$idx]"; } else { error("Vote value out of range"); } } echo "<br/>\n"; } else { // echo "No votes yet<br/>\n"; } ?> <? endwhile; ?> <? else: ?> No matches! <? endif; ?> Go back<anchor title="back"><prev>back</prev></anchor> </p> </card> <? require("stdwapftr.tpl"); ?>


    This article copyright GBdirect Ltd 2000. All rights reserved. Reprinted from http://www.gbdirect.co.uk/ with permission.

    More PHP Articles
    More By Mike Banahan


     

       

    PHP ARTICLES

    - Using Aliases and the Autoload Function with...
    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Sub Classing Exceptions in PHP 5
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT