Home  >  Article  >  Backend Development  >  Application of PHP programming in WAP development_PHP tutorial

Application of PHP programming in WAP development_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:38:02797browse

We can use PHP to write WAP programs, such as developing dynamic WML pages, but the condition is that the output tags or statements need to be limited to the acceptable range of the WAP micro-browser. Moreover, PHP can also write content suitable for both HTML (and HDML) and WML in an HTML (and HDML) file. The source code of PHP is invisible to the WAP client, so we can output HTML pages for HTML browsers, and output HDML pages or WML pages for WAP browsers.

11.3.1 Basic Rules

Taking WML as an example, the basic rules for writing WML programs using PHP are as follows:

(1) Use "" to include WML program lines written in PHP, the format is:

......(program line);

?>

(2) Program line statements all end with a semicolon (;), which is different from ASP writing WML programs.

(3) Use PHP’s 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 specially adopted for WAP browser recognition. If the user during development wants to use an ordinary browser, such as IE browser, to test the program effect, he can add double slashes (//) in front of the statement in the format:

// header("Content-type: text/vnd.wap.wml");

In this way, PC-based browsers will ignore WML tags that cannot be understood in the program, and the current program will actually become an HTML page. When you want to test on a WAP device or emulator, you only need to remove "//" and the current page will automatically become a WML page.

(4) Other WML tags and statement lines must be declared using PHP’s echo keyword, and a newline character is added after each WML line. "(You can also add more as needed). Its basic format is:

echo("...(WML tag and statement line) ");

For example, the following statement is a typical example of writing a WML statement line in PHP:

echo(" ");

Moreover, the "WML tags and statement lines" in the echo statement can be written consecutively to save lines of program code. For example, the following line of statement contains three lines of WML tag statements:

echo ("

");

(5) Declaration of scripting language. This is an inheritance of PHP programming. It declares to the compiler that the scripting language used by the current program is PHP. The format is: