PHP dynamic WAP page 3_php tutorial

Source: Internet
Author: User
PHP generates dynamic WAP page 3. 3. use PHP to dynamically generate images. the WAP application uses a special black/white image format WBMP. We can use some tools to convert existing images into WBMP format and then use them in WML documents. 3. use PHP to dynamically generate images
The WAP application uses a special black/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 the K-line chart can be dynamically generated on the WAP site, there will be broad application prospects. Fortunately, PHP's GD Library (version 1.8 or later) already provides functions.
$ #@ 60 ;? PHP
Header ("Content-type: image/vnd. wap. wbmp ″);
Sim = ImageCreate (50, 50 );
Swhite = ImageColorAllocate (Sim, 255,255,255 );
Sblack = ImageColorAllocate (Sim, 0, 0 );
ImageRectangle (Sim, 5, 5, 20, 20, Sblack );
ImageWBMP (Sim); ImageDestroy (Sim );
? $ #@ 62;
This file will display a black rectangular box in the WAP simulator. Note that to use the GD Image function library, you must load the PHP_GD.DLL library file in the PHP configuration.
4. process Chinese characters in PHP
As a global application, WAP uses UNICODE 2.0 as its standard character set encoding so that it can simultaneously process a variety of texts, including English, Chinese, Japanese, and French. We usually use GB2312 encoding for processing Chinese characters, and different internal code standards are bound to be unavailable. Therefore, if the two encoding formats are not converted using a code table, Chinese characters may be garbled. Now there are more mature GB-2312 and UNICODE conversion procedures and functions, and in ASP, PHP, JSP and other systems, we can find them on some technical sites.
Currently, most WAP mobile phones (Nokia7110, Ericsson R320S and so on) are encoded using UTF-8, that is, UNICODE. In this way, if we use Chinese characters (GB2312 encoding) in WML, garbled characters will be generated and cannot be identified by mobile users. Therefore, before outputting Chinese characters, UNICODE must be encoded using a program or function. In a few mobile phones or WAP devices that support GB2312 encoding, we can define the document internal code type in the program to directly display Chinese characters, for example:

$ #@ 60 ;? Php
Header ("Content-type: text/vnd. wap. wml; charset = gb2312 ″);
Echo ("$ # @ 60; wml $ # @ 62; $ # @ 60; card $ # @ 62; $ # @ 60; p $ # @ 62 ;″);
Echo ("Chinese test ″);
Echo ("$ # @ 60;/p $ # @ 62; $ # @ 60;/card $ # @ 62; $ # @ 60;/wml $ # @ 62; ″);? $ #@ 62;

The WAP application uses a special black/white image format WBMP. We can use some tools to convert existing images to the WBMP format and then use them in WML documents ....

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.