Home  >  Article  >  Backend Development  >  PHP generates dynamic WAP page 3_PHP tutorial

PHP generates dynamic WAP page 3_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:28:36873browse

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.
 $#@60;?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, 20, 20, Sblack);
ImageWBMP(Sim); ImageDestroy(Sim) ;
 ?$#@62;
  The file will display a black rectangle in the WAP emulator. 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 by 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:


 $#@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;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531767.htmlTechArticle3. 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. ...
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