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 communications, static WAP pages in many ways can not meet the user's personalized requirements, so developers can use in the WAP server, such as PHP and other languages to generate dynamic WML page, to meet the needs of users.
The application structure of WAP is very similar to the Internet, a typical WAP application request step is described as follows:
1. A mobile terminal (such as a WAP phone) with a WAP user agent function that sends a WAP service request to a Web site through an in-house micro-browser. This request is intercepted by WAP gateway, encoding the content of the information to reduce the traffic of network data, and convert the WAP protocol to HTTP protocol as needed.
2. The protocol transmits the processed request to the corresponding WAP server. On the WAP server side, according to the attributes such as the page extension, the requested page is exported directly or by the server-side script, and then passed back to the user through the gateway.
From the above WAP application process, we can find that the process of generating dynamic WAP pages is very similar to that of dynamically generating web pages. However, since the WML language used in WAP applications originates from the strict syntax of XML, the required output format must be exported according to the specification of WAP Web pages. At the same time, because of the application scope of WAP protocol and the limitation of software and hardware configuration of mobile client, there are some restrictions on the size of each output page, the format and the capacity of the image. In this paper, the author 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 typical Web page, the author introduces it through one of the simplest examples of WAP pages. But the caveat: because you need a PHP interpreter to interpret the program and output a WAP page, all similar programs should be "PHP" extensions.
< PHP
Header ("CONTENT-TYPE:TEXT/VND.WAP.WML"); To define the output document as a WML type
Echo ("");
Echo ("Hello WAP");
Echo ("");
?>
This example can be browsed in 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 WML type, only WAP devices can recognize and explain. But another caveat: the common HTML language is not strict with the normative requirements, most browsers can "tolerate" the written error, but the WML specification is very strict, any error may result in the inability to output the required page.
Instance 1 dynamically generating images
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 into wbmp formats and then use them in WML documents. However, if the required images can be generated dynamically in the WAP program (such as the K-line chart of the stock market), the program will have an extremely broad application prospect. PHP provides a powerful graphical rendering function, and the following example displays a black rectangular box in the WAP emulator.
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.