PHP generates a dynamic WAP page

Source: Internet
Author: User
Tags echo date install php php script
WAP (Wireless Communication Protocol) is an open global standard for communication between digital mobile phones, personal handheld devices (PDAs, etc.) and computers. Because the static WAP page can not satisfy the user's personalized service request in many aspects, it has a wide application value and high commercial value to produce dynamic WML pages through the WAP server-side language.
WAP application architecture is very similar to the Internet, a typical WAP application request is as follows: first, mobile terminals with WAP user agents (WAP phones, etc.) wirelessly send WAP service requests to a Web site via an Micro Browser. This request is intercepted by WAP gateway, encode the content of the information to reduce the traffic of network data, Convert WAP protocol to HTTP protocol as needed, and then transfer the processing request to the corresponding WAP server. On the WAP server side, according to the nature of the page extension, the requested page is exported directly or by the server-side script, and then the user is passed back through the gateway.
From the above WAP application process, we can see 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, the level of software and hardware of mobile client, the size of each output page, image format and capacity are limited. Let's take the PHP scripting language for example to see how to dynamically output a WAP page.
First, set up a Web server
First of all, your Web server to install PHP, that can handle PHP script program. Second, to enable the Web server to recognize and process PHP, WML, and wbmp files at the same time, the MIME table for the Web server needs to add the following file types.
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
Second, with PHP output simple dynamic WAP page
Here is an example of the simplest PHP-generated WAP page. Note that because you need a PHP interpreter to interpret the program and output a WAP page, all similar programs should have the. 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 can be browsed in the WAP phone simulator, output the current date time, and in the ordinary browser is not recognized, and may even be considered a wrong download. This is because the output document is declared as a WML type at the beginning of the program, and only the WAP device can recognize and interpret it. It is worth noting that our common HTML language is not stringent requirements, most browsers can "tolerate" a considerable number of writing errors, and the WML specification is very strict, a bit of error can lead to the inability to output the required pages.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.