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, we can use PHP to write WAP programs, such as developing dynamic WML pages. However, 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" 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 PHP echo keyword. each WML line is followed by the line break "" (you can add multiple lines as needed ). The basic format is:
Echo ("...... (WML label and statement line )");
For example, the following statement is a typical example of compiling a WML statement line in PHP:
Echo (" ");
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 ("
");
(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: