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  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
PHP

WAP-Enabling a Website with PHP3
By: Mike Banahan
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 22
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek