Cyprich.com

Occasionally Relevant Insights from a Software Builder

By

Using PHP with Mobile XHTML

Mobile XHTML is the best markup language for mobile browsers as opposed to WAP. XHTML, however, does have limitations which can be solved by dynamic scripting. If you renamed the page’s extension from html to php, the page will not display in a mobile browser. I spent a great deal of time searching the Internet for a solution and not one site could help me. After some thought, I discovered how to create a mobile PHP page.

A Mobile XHTML page has 2 HTML tags at the start of the page. If you remove these tags, the page will not display correctly. A PHP page must begin with the following bit of code in order to display:

< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">

This code must appear at the very beginning of the PHP page before the HTML tag. From there, you can use any PHP function available.

2 Responses to Using PHP with Mobile XHTML

  1. m1dp1d says:

    Hallo Admin!

    I’m a mobile device developer and I have exactly the same problem you’ve been talking about on 02 May 2006. You are one of few who’s addressing this problem. But unfortunately I’m still not able to display any php file on diverse SDK’s. (Openwave, Nokia, …). Can you please give me some additional advice/help how to create pages with php content.

    It doesn’t work if I create a file with the file extension *.php that has the following content:

    ‘;
    echo ”;
    ?>

    In another forum I was told to use the following code as a header:

    header(‘Content-Type: application/xhtml+xml;’);

    Thanks in advance

  2. admin says:

    Can you resend the code that you are having trouble with? A problem with WordPress is that it filters out PHP code from messages. I just installed a plug-in which will allow you to place PHP a message. You need to enclose your code in code or pre HTML tags.

    I already have a moble PHP web site that you can try (mobile.holysouls.info). I haven't updated the site with the latest content yet, but it definitely works on my Nokia 3100.