Application of PHP programming in WAP Development

Source: Internet
Author: User

 

Application of PHP programming in WAP Development
We can use PHP to write WAP programs, such as developing dynamic WML pages, but the condition is that the labels or statements output must be within the acceptable range of the WAP micro-browser. In addition, PHP can also compile HTML (and hdml) and WML content in an HTML (and hdml) file. The source code of PHP is invisible to the WAP client, so we can output HTML pages for the HTML browser and hdml pages for the WAP browser.
11.3.1 basic rules
Taking WML as an example, the basic rules for compiling WML programs using PHP are as follows:
(1) Use "<?" And "?>" Contains the WML program lines written in PHP. The format is:
<?
...... (Program line );
?>
(2) The program line statements end with a semicolon (;), which is different from ASP's WML program.
(3) Use the PHP header keyword to declare the WML file type. The basic format is:
Header ("Content-Type: text/vnd. WAP. WML ");
The above format is a writing format designed for WAP browser recognition. If you want to use a normal browser, such as IE browser, to test the program effect, you can add a double slash (//) before the statement in the format:
// Header ("Content-Type: text/vnd. WAP. WML ");
In this way, the PC-based browser will ignore the WML labels that cannot be understood in the program. At this time, the current program actually becomes an HTML page. To test on a WAP device or simulator, you only need to remove "//" and the current page will automatically become a WML page.
(4) Other WML labels and statement lines are declared using the echo keyword of PHP. The linefeed "/N" is added to each WML line (multiple lines can be added as needed ). The basic format is:
Echo ("...... (WML label and statement line)/n ");
For example, the following statement is a typical example of compiling a WML statement line in PHP:
Echo ("<? XML version =/"1.0/"?> /N ");
In addition, the "WML label and statement line" in the ECHO statement can be connected to save the program code line. For example, the following line of statements is a three-line tag Statement of WML:
Echo ("<WML> <card> <p> ");
(5) Declare the scripting language. This is an inheritance of PHP programming. It declares to the compiler that the current script language used by the program is Php, in the format:
<Script language = "php">
However, this sentence can be omitted because the compiler can automatically recognize PHP scripts.
(6) The file is last saved with the extension ". php" or ". php3" instead of ". WML.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.