Openlot Systems

4.3 How can I use PHP to make WML contents more dynamic?

PHP (and most other server side script languages) can be used to make your WML contents dynamic in that they can do all the work and squeeze the output into the narrow format that the WML micro browser in your WAP device accepts. Check the PHP web site for more info on PHP.

Note that some built-in features of PHP outputs HTML, typically error messages, which your WML micro browser will not understand.

PHP is so flexible that one HTML document containing a PHP script can be used for both HTML and WML compatible browsers. The PHP source code is invisible to the client, and it's simply up to you to either output HTML code when the browser is a HTML compatible browser, and WML code when the browser is a WML compatible browser.

A PC based browser can be used during development of the PHP WML code by adding this PHP code to the very top of your page:

  // header("Content-type: text/vnd.wap.wml");
  echo("<?xml version=\"1.0\"?>\n");
  echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://...\">\n\n");

The PC based browser will ignore any WML tags it doesn't understand. Then, when you are ready to try the code on your WAP device or WAP device emulator, you simply remove the two slashes (//) in front of the "header" command (uncommenting it), and the page automatically becomes a WML deck.

[ Main ]   [ 04 - Serving WML contents ]