PHP generated Dynamic WAP page (c)

Source: Internet
Author: User
Tags format character set header
Dynamic | Page Three, dynamically generate images with PHP

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 work with them in WML documents. However, if we can dynamically generate the required images such as chart on the WAP site, there will be a wide application prospect. Fortunately, PHP's GD library (version 1.8 or more) already provides the appropriate function.

? Php
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, Sblack,);
Imagewbmp (Sim); Imagedestroy (Sim);
?>

The file will display a black rectangular box in the WAP emulator. Note To use the image Library of GD, you must load the PHP_GD in your PHP configuration. DLL library file.

Iv. handling Chinese characters in PHP

As a global application, WAP has chosen Unicode 2.0 as its standard character set encoding so that it can simultaneously handle multiple languages, including English, Chinese, Japanese, and French. And we usually deal with the use of Chinese characters is GB2312 encoding, the different internal code standards will not be universal, so if not between the two codes through the Code table to convert, the phenomenon of Chinese characters garbled. Now there are more mature GB-2312 and Unicode code conversion programs and functions, and in ASP, PHP, JSP and other systems used, we can find them on some technical sites.

Most of the current WAP phones (Nokia7110, Ericsson r320s, etc.) are encoded using the UTF-8 code, which is encoded using Unicode. In this way, if we use Chinese characters (GB2312 encoding) directly in WML, the code will be garbled and the cell phone user cannot recognize it, so we will use the program or function to encode the Chinese in Unicode before we export the language. In a few mobile phones or WAP terminals that support GB2312 encoding, we can directly display Chinese characters correctly after we have defined the code type of the document in the program, for example:

<?php
Header (″CONTENT-TYPE:TEXT/VND.WAP.WML; charset=gb2312″);
Echo (″<wml><card><p>″);
Echo (″ Chinese test ″);
Echo (″</p></card></wml>″);
?>


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.