Home >Backend Development >PHP Tutorial >winamp 5.07 pro simplified Chinese enhanced version php generates WAP page

winamp 5.07 pro simplified Chinese enhanced version php generates WAP page

WBOY
WBOYOriginal
2016-07-29 08:34:481130browse

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 uses a micro browser (Micro Browser) running internally to access a website. Send WAP service request 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, based 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 is derived 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 output, the format and capacity of the image each time. 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, 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
 The following 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.
  header(″Content-type: text/vnd.wap.wml″);
 echo (″

″);
 echo date( ″l dS of f The date and time cannot be recognized by ordinary browsers, and may even be considered as 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.
 Once we know the standard process of using PHP scripts to output WAP pages, we can use the powerful functions of PHP with the interactive processing of WML language and the simple scripts of WML Script to develop an application system that suits our needs.
3. Use PHP to dynamically generate images
 WAP applications use a special black and white image format WBMP. We can use some tools to convert existing images into WBMP format and then use them in WML documents. However, if the required images such as K-line charts can be dynamically generated on the WAP site, there will be broad application prospects. Fortunately, PHP's GD library (version 1.8 and above) already provides corresponding functions.
  Header(″Content-type: image/vnd.wap.wbmp″);
 Sim = ImageCreate(50, 50);
 Swhite = ImageColorAllocate(Sim,255,255,255);
 Sblack = ImageColorAllocate(Sim, 0,0,0);
 ImageRectangle(Sim, 5, 5, 20, 20, Sblack);
 ImageWBMP(Sim); ImageDestroy(Sim);
  ?>
 The file will display a black color in the WAP simulator Rectangle. Note that to use GD's image function library, the PHP_GD.DLL library file must be loaded in the PHP configuration.
 IV. Processing Chinese characters in PHP
 As a global application, WAP has chosen UNICODE 2.0 as its standard character set encoding so that it can process multiple texts including English, Chinese, Japanese, French, etc. at the same time. We usually use GB2312 encoding to process Chinese characters. Different internal code standards are bound to be incompatible. Therefore, if the code table is not converted between the two encodings, garbled Chinese characters will appear. There are already relatively mature programs and functions for GB-2312 and UNICODE encoding conversion, and they are used in ASP, PHP, JSP and other systems. We can find them on some technology sites.
Most of the current WAP mobile phones (Nokia7110, Ericsson R320S, etc.) use UTF-8 encoding, which is encoded using UNICODE.In this way, if we use Chinese characters (GB2312 encoding) directly in WML, garbled characters will be generated and mobile phone users cannot recognize them. Therefore, before we output Chinese, we must use a program or function to encode the Chinese with UNICODE. In a small number of mobile phones or WAP terminal devices that support GB2312 encoding, we can directly and correctly display Chinese characters after defining the internal code type of the document in the program, for example:
  header(″Content-type: text /vnd.wap.wml; charset=gb2312″);
 echo (″

″);
 echo (“Chinese test”);
 echo (″

″);
  ?>
Original author: Unknown
Source: php Free Alliance

The above introduces the WAP page generated by winamp 5.07 pro simplified Chinese enhanced version php, including the content of winamp 5.07 pro simplified Chinese enhanced version. I hope it will be helpful to friends who are interested in PHP tutorials.

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