×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    2

    PHP embedded in WML

    I am strictly a newby at this.

    I am basically trying to get a feel as to exactly how PHP fits into WML. I am using the NMIT 4.0 and the Nokia Mobile Browser 4.0 to view the output of my compiled code.

    My problem is this:

    when i compile and run the code, the output shows everything but the PHP script. I am trying a simple example (atleast its supoosed to be) where the current date is outputted to the screen...


    here's my code:

    <?xml version="1.0"?>
    <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.org/DTD/wml_1.1.xml">
    <?php
    // send wml headers
    header("Content-type: text/vnd.wap.wml");
    ?>

    <wml>

    <card id="card1" title="Example 1">
    <p>
    <do type="accept">
    <go href="#card2"/>
    </do>
    <?php
    // format and output date
    $the_date = date("M d Y");
    print $the_date;
    print "<br/>Welcome to a PHP-enabled site!";
    ?>
    </p>
    </card>

    </wml>


    I'm confused! It only out puts the title of the card (Example 1). Please help!

    peter bezanson

  2. #2
    Registered User
    Join Date
    Mar 2003
    Location
    Warsaw, PL
    Posts
    4
    Try to write it like that:

    <?php
    // send wml headers
    // headers should be sent before any other content
    header("Content-type: text/vnd.wap.wml");
    ?>
    <?xml version="1.0"?>
    <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
    "http://www.wapforum.org/DTD/wml_1.1.xml">

    <wml>

    <card id="card1" title="Example 1">
    <!-- the "do" element should be before "p" tag. -->
    <do type="accept">
    <go href="#card2"/>
    </do>
    <p>
    <?php
    // format and output date
    $the_date = date("M d Y");
    print $the_date;
    print "<br/>Welcome to a PHP-enabled site!";
    ?>
    </p>
    </card>

    </wml>

  3. #3
    Registered User
    Join Date
    Aug 2003
    Location
    Greece,Athens
    Posts
    17

    Some usefull things about php and wml

    Hello ,

    Well , you can write " ob_start(); "
    function on the top of your php code , and with that php will output first all headers and then any other outpout .

    Olso , check your code :
    <?xml version="1.0"?>
    PHP will parse that part cause it is in <? ?> !! You can do :

    echo '<?xml version="1.0"?>\n' ;

    Carefull ! ' , not " .
    I hope I helped a little .

  4. #4
    Registered User
    Join Date
    Mar 2003
    Location
    New Zealand
    Posts
    9

    A Handy xml + header info include file

    Bung this code into an include file and then call it whenever you want some new output:

    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";

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×