Home  >  Article  >  Backend Development  >  PHP generates dynamic WAP pages_PHP tutorial

PHP generates dynamic WAP pages_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:05:02856browse

WAP (Wireless Communication Protocol) is an open global standard for communication between digital mobile phones, personal handheld devices (PDA, etc.) and computers. Since static WAP pages cannot meet users' personalized service requests in many aspects, dynamic WML pages generated through WAP server-side language have wide application value and high commercial value.
The WAP application structure is very similar to the Internet. A typical WAP application request is as follows: First, a mobile terminal (WAP mobile phone, etc.) with WAP user agent function requests a certain Websites send WAP service requests wirelessly. The request is first intercepted by the WAP gateway, which encodes and compresses the information content to reduce network data traffic. At the same time, the WAP protocol is converted into the HTTP protocol as needed, and then the processed request is forwarded to the corresponding WAP server. On the WAP server side, depending on the page extension and other properties, the requested page is output directly or is interpreted by a server-side script, and then transmitted back to the user through the gateway.
From the above WAP application process, we can see that the process of generating dynamic WAP pages is very similar to the process of dynamically generating Web pages. However, since the WML language used by WAP applications comes from XML with strict syntax, the output format must be output according to the specifications of the WAP web page. At the same time, due to the application scope of the WAP protocol and the software and hardware level of the mobile client, there are certain restrictions on the size of the page, image format and capacity each time it is output. Let's take the PHP script language as an example to see how to dynamically output a WAP page.
1. Set up the WEB server
First of all, your Web server must have PHP installed, that is, it can handle PHP scripts. Secondly, in order for the Web server to recognize and process PHP, WML, WBMP and other files at the same time, the following file types need to be added to the MIME table of the Web server.
text/vnd.wap.wml .wml
image/vnd.wap.wbmp .wbmp
application/vnd.wap.wmlc .wmlc
text/vnd.wap.wmls.wmls
Application/vnd.wap.wmlsc .wmlsc
2. Use PHP to output a simple dynamic WAP page
Here is the simplest example of PHP generating a WAP page. Note that since a PHP interpreter is required to interpret this program and output the WAP page, all similar programs should have a .php extension.
  ?php
 header(″Content-type: text/vnd.wap.wml″);
 echo (″〈wml〉 〈card〉 〈p〉″);
 echo date( ″l dS of F Y h:i:s A″ );
echo (″〈/p〉〈/card〉〈/wml〉″);
 ?〉
 This example is in the WAP mobile phone simulator It can be browsed in and output the current date and time, but it cannot be recognized in ordinary browsers and may even be considered an error download. This is because the output document is declared as WML type at the beginning of the program, and this type can only be recognized and interpreted by the WAP device. It is worth noting that our common HTML language does not have strict normative requirements, and most browsers can "tolerate" quite a lot of writing errors, while WML specifications are quite strict, and a single mistake may result in the failure to output the required page.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445158.htmlTechArticleWAP (wireless communication protocol) is carried out between digital mobile phones, personal handheld devices (PDA, etc.) and computers An open global standard for communications. Since static WAP pages are not efficient in many aspects...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn