I use .htaccess like this

<Files google_base_feed.xml>
ForceType application/x-httpd-php5
</Files>

tell my server to run "google_base_feed.xml" as a php file, and generate the xml page.

1) I think

<Files google_base_feed.wml>
ForceType application/x-httpd-php5
</Files>

Will do the same, tell my server to run "google_base_feed.wml" as a php file, and generate the wml page.

Am I right?

2) How about url like the following

google_base_feed.xml?id=1
or
google_base_feed.wml?id=2

They will still run as php and generate the xml or wml pages. but

.xml?id=1 pr .wml?id=2,. are they legitimate xml or wml url? rss or mobile micro browser accept them?

3) how do you use php to generate xml and wml? specially in the case like query string parameter needed, like .xml?id=1, wml?id=2

Thanks!

    Exactly the same way you do it for HTML. PHP doesn't care what it outputs.

    The only thing you'll probably want to do different is use [man]header[/man] to specify the appropriate Content-Type.

      Thanks! Yes, the header. Specially fore fire fox, I need to set up the header right.

      I understand that php doesn't care. But how about xml or wml, would they care?

      is .xml?id=1 legitimate xml url such as for rss?

      or

      is .wml?id=2 legitimate wml url for micro browser on mobile phone?

      I thought they are. But I am not sure if they are legitimate in all situations.

        .fubar?id=1 is valid, as long as (a) your web server is configured to process .fubar files as PHP, and (b) the file in question outputs the desired HTTP header, e.g.:

        <?php
        header('Content-Type: text/xml');
        ?>
        

        For that matter, you can just use a .php suffix and not worry about changing the web server config, as long as you send that header. The header will tell the client what type of data it is receiving, not the file name suffix you use for it on the server.

          OK, not the extension but the header tell the browser what the page is?

          so as long as I have my header set up right, the extension could be .php or .xml, it doesn't matter?

          So for clean url such as CodeIgniter, I don't have to have extension at all for xml pages?

          Such as

          http://www.mysite.com/feed

          Will be fine as a rss feed url, as long as I set up the header right?

          How about wml, same case?

          If I didn't set up the header right, I have to use the wml extension, but if I set the header for wml, such as

          <?php header('Content-Type: text/vnd.wap.wml, charset=utf-8'); ?>

          then I can use any extension, such as .php, or in clean url case, no extension at all?

            Yes, it should be fine that way. A possible exception might be something like a PDF that actually gets launched by a separate application, or if you want to otherwise send the output as a file to be downloaded instead of displayed by the browser. In that case you would need a "content-disposition" header:

            <?php
            header('Content-Type: application/pdf');
            header('Content-Disposition: attachment; filename="foo.pdf"');
            

              OK

              Here is the code for a file called map.wml, which works fine.

              <?xml version="1.0"?>
              
              <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
              "http://www.wapforum.org/DTD/wml_1.1.xml">
              <wml>
                <card title="Image">
                  <p>This is a map
                  <img src="http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile\
              &markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc\
              &key=MAPS_API_KEY&sensor=false" alt="map" />
                  in a paragraph</p>
                </card>
              </wml>
              

              Here is the code for a file called map.php

              <?php header('Content-Type: text/vnd.wap.wml, charset=utf-8'); ?>
              <?php
              	 $xml_version = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
              	 echo $xml_version;
              
              ?>
              <wml>
                <card title="Image">
                  <p>This is a map
                  <img src="http://maps.google.com/staticmap?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mobile\
              &markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc\
              &key=MAPS_API_KEY&sensor=false" alt="map" />
                  in a paragraph</p>
                </card>
              </wml>
              

              The difference is that the second file is a php, but I set up the header

              <?php header('Content-Type: text/vnd.wap.wml, charset=utf-8'); ?>

              I tried this on several wml samples, which works fine. But for this sample, map.wml works fine when I check it in the emulator, http://www.wapsilon.com/

              map.wml works. But map.php get xml parse error.

              Parser failed. Invalid XML syntax.
              not well-formed (invalid token) at line 5, column 79, byte 172 
              

              Any ideas?

              Thanks!

                In the <img> tag, try changing the & characters to the &amp; character entity.

                  Thanks! Yes replaced & and It is working fine now!

                  One more question, I am new to wap developing.

                  But when I google the wap or specially "php and wap", not too many results there, and many results are old. Like wap or wml threads in this forum are old too.

                  Given the new mobile phones were so hot in the past years, it seemed not too much new exciting stuff in php and wap application recently, or my feeling was wrong?

                  I was thinking google "php and wap or php and wml" it will return millions results of the new technology new applications etc.

                  Any knowledge, experience you can share about "php and wap"? What a php developer should know when get into wap development?

                  Thanks!

                    There's not much point searching for "php and wap". PHP doesn't care what it outputs and WAP doesn't care what generates it and programming is programming either way.

                    Then again, most cellphones these days are quite happy using HTML, especially with an appropriate stylesheet to accommodate for the small form factor.

                      Thanks! I was wondering about why wml samples or threads are all old.

                      So today, cell phone web sites don't have to be on WML / WMLSCript. Regular xhtml, javascript will do.

                      All I need to find out is the guides (resource) that tell about principles/rules/... of using xhtml/javascript in WAP today?

                      So for a php developer wants to work in a mobile programming area, what kind advices/resources you guys can give or recommend?

                      Thanks!

                        Write a Reply...