Hi,
AFAIK the only way to do this is to make e.g. apache to interpret .wml files as php:
AddType application/x-httpd-php .php .wml
DirectoryIndex index.wml
You have to use header calls to make things working.
Example:
<?php
header("Content-Type: text/vnd.wap.wml;charset=iso-8859-1");
echo "\n\n<"."?xml version=\"1.0\"?".">\n";
?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
Then continue with your code (and give the scripts an extension of .wml)
You must specify a charset like above because it could cause problems otherwise.
This should work 🙂
If you don't have access to the server configuration (e.g. httpd.conf) a .htaccess file could be sufficient.
I couldn't test the above code, hope it works 🙂