WAP (Wireless Communication Protocol) is an open global standard protocol for communication between digital mobile phones, personal handheld devices (PDAs, etc.) and computers. With the continuous development of wireless communication, static WAP pages in many aspects can not meet the user's personalized requirements, so developers can use the WAP server, such as PHP to generate dynamic WML pages, to meet the needs of users.
WAP application structure is very similar to the Internet, a typical WAP application request step is described as follows:
1. Mobile Terminal with WAP user agent function (such as WAP mobile phone), send WAP service request to a website through a micro browser running inside. The request is intercepted by WAP Gateway, and the information content is encoded and compressed to reduce network data traffic, and the WAP protocol is converted to HTTP protocol.
2. The Protocol forwards the processed request to the appropriate WAP server. In the WAP server side, according to the page extension and other properties, the requested page is interpreted directly or by the server-side script output, and then passed back to the user through the gateway.
From the WAP application process described above, the generation of dynamic WAP pages is very similar to the process of generating web pages dynamically. However, because the WML language used by WAP applications comes from syntax-Strict XML, the format required for the output must be output in accordance with the specifications of the WAP Web page. At the same time, due to the application scope of WAP protocol and the limitation of software and hardware configuration of mobile client, there are certain limitations on the size of each output page, the format and the capacity of the image. This article will take the PHP language as an example, and the vast number of network program development enthusiasts to explore the dynamic output WAP page method and application.
Output a simple dynamic WAP page
Because the process of generating a WAP page is very similar to generating a generic Web page, the author introduces it through an example of the simplest WAP page. However, as a reminder: because the PHP interpreter is required to interpret the program and output WAP pages, all similar programs should be "PHP" extension Oh.
Header ("CONTENT-TYPE:TEXT/VND.WAP.WML"); Define the output document as WML type
Echo ("Hello WAP");
This example can be browsed in the WAP phone simulator, output a classic "Hello WAP" statement, but in the ordinary Web browser is not recognized, the reason is very simple, at the beginning of the program declared that the output document is a WML type, only the WAP device can be recognized and interpreted. However, it is important to note that the common HTML language is not strict with the normative requirements, most browsers can "tolerate" to accept the writing errors, but the WML specification is very strict, any error can cause the output of the required page.
Example 1 generating images dynamically
The image used by WAP is a special black-and-white image format: WBMP. Developers can use some of the existing tools to convert generic images to wbmp format and then use them in WML documents. However, if the desired image can be generated dynamically in the WAP program (such as the candlestick Chart of the stock market), the program will have a very wide application foreground. PHP provides powerful graphics rendering, and the following example displays a black rectangular box in the WAP simulator.
http://www.bkjia.com/PHPjc/445222.html www.bkjia.com true http://www.bkjia.com/PHPjc/445222.html techarticle WAP (Wireless Communication Protocol) is an open global standard protocol for communication between digital mobile phones, personal handheld devices (PDAs, etc.) and computers. With the continuous development of wireless communication, static ...