


Detailed discussion of PHP WEB server related knowledge_PHP tutorial
We all know the power of PHP. Recently we have seen relevant knowledge about PHP WEB server. Let’s discuss this issue with you. 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.
As can be seen from the above WAP application process, 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, image format and capacity each time it is output. Let's take the PHP script language as an example to see how to dynamically output a WAP page.
1. Set up PHP WEB server
First of all, your web server must have PHP installed, that is, it can handle PHP scripts. Secondly, in order for the PHP 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.
<ol class="dp-xml"> <li class="alt"><span><span>text/vnd.wap.wml .wml </span></span></li> <li class=""><span> </span></li> <li class="alt"><span>image/vnd.wap.wbmp .wbmp </span></li> <li class=""><span> </span></li> <li class="alt"><span>application/vnd.wap.wmlc .wmlc </span></li> <li class=""><span> </span></li> <li class="alt"><span>text/vnd.wap.wmls.wmls </span></li> <li class=""><span> </span></li> <li class="alt"><span>application/vnd.wap.wmlsc .wmlsc </span></li> </ol>
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.
<ol class="dp-xml"> <li class="alt"><span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN></FONT></STRONG><SPAN> </SPAN></SPAN><LI class=""><SPAN>header(″Content-type: text/vnd.wap.wml″); </SPAN><LI class=alt><SPAN>echo (″</SPAN><STRONG><FONT color=#006699><SPAN class=tag><</SPAN><SPAN class=tag-name>wml</SPAN><SPAN class=tag>></span></font></strong><span> </span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>card</SPAN><SPAN class=tag>></span></font></strong><span> </span><strong><font color="#006699"><span class="tag"><</SPAN><SPAN class=tag-name>p</SPAN><SPAN class=tag>></span></font></strong><span>″); </span></span></li> <li class=""><span>echo date( ″l dS of F Y h:i:s A″ ); </span></li> <li class="alt"> <span>echo (″</span><strong><font color="#006699"><span class="tag"></</SPAN><SPAN class=tag-name>p</SPAN><SPAN class=tag>></span><span class="tag"></</SPAN><SPAN class=tag-name>card</SPAN><SPAN class=tag>></span><span class="tag"></</SPAN><SPAN class=tag-name>wml</SPAN><SPAN class=tag>></span></font></strong><span>″); </span> </li> <li class=""> <span></span><span class="tag"><strong><font color="#006699">?></font></strong></span><span> </span> </li> </ol>
This example can be browsed in the WAP mobile phone simulator and outputs the current date and time, but it cannot be recognized in ordinary browsers and may even be considered 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 script to output WAP pages, we can use the powerful functions of PHP with the interactive processing of WML language and simple scripts of WML script to develop applications that suit our needs. System.
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.
<ol class="dp-xml"><li class="alt"> <span><strong><font color="#006699"><span class="tag"><?</SPAN><SPAN class=tag-name>PHP</SPAN></FONT></STRONG><SPAN> </SPAN></SPAN><LI class=""><SPAN>Header(″Content-type: image/vnd.wap.wbmp″); </SPAN><LI class=alt><SPAN></SPAN><SPAN class=attribute><FONT color=#ff0000>Sim</FONT></SPAN><SPAN> = </SPAN><SPAN class=attribute-value><FONT color=#0000ff>ImageCreate</FONT></SPAN><SPAN>(50, 50); </SPAN></SPAN><LI class=""><SPAN></SPAN><SPAN class=attribute><FONT color=#ff0000>Swhite</FONT></SPAN><SPAN> = </SPAN><SPAN class=attribute-value><FONT color=#0000ff>ImageColorAllocate</FONT></SPAN><SPAN>(Sim,255,255,255); </SPAN></SPAN><LI class=alt><SPAN></SPAN><SPAN class=attribute><FONT color=#ff0000>Sblack</FONT></SPAN><SPAN> = </SPAN><SPAN class=attribute-value><FONT color=#0000ff>ImageColorAllocate</FONT></SPAN><SPAN>(Sim,0,0,0); </SPAN></SPAN><LI class=""><SPAN>ImageRectangle(Sim, 5, 5, 20, 20, Sblack); </SPAN><LI class=alt><SPAN>ImageWBMP(Sim); ImageDestroy(Sim); </SPAN><LI class=""><SPAN></SPAN><SPAN class=tag><STRONG><FONT color=#006699>?></span></font></strong></span><span> </span> </li></ol>
The file will display a black rectangular box in the WAP emulator. Note that to use the GD image function library, the PHP_GD.DLL library file must be loaded in the PHP WEB server configuration.
4. Processing Chinese characters in PHP
WAP, as a global application, has chosen UNICODE 2.0 as its standard character set encoding so that it can simultaneously process English, Chinese, Japanese, French and other languages. 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 current WAP 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 few 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:
<ol class="dp-xml"> <li class="alt"><span><span class="tag"><?</SPAN><SPAN class=tag-name>php</SPAN><SPAN> </SPAN></SPAN><LI class=""><SPAN>header(″Content-type: text/vnd.wap.wml; </SPAN><SPAN class=attribute>charset</SPAN><SPAN>=</SPAN><SPAN class=attribute-value>gb2312</SPAN><SPAN>″); </SPAN></SPAN><LI class=alt><SPAN>echo (″</SPAN><SPAN class=tag><</SPAN><SPAN class=tag-name>wml</SPAN><SPAN class=tag>></span><span class="tag"><</SPAN><SPAN class=tag-name>card</SPAN><SPAN class=tag>></span><span class="tag"><</SPAN><SPAN class=tag-name>p</SPAN><SPAN class=tag>></span><span>″); </span></span></li> <li class=""><span>echo (″中文测试″); </span></li> <li class="alt"> <span>echo (″</span><span class="tag"></</SPAN><SPAN class=tag-name>p</SPAN><SPAN class=tag>></span><span class="tag"></</SPAN><SPAN class=tag-name>card</SPAN><SPAN class=tag>></span><span class="tag"></</SPAN><SPAN class=tag-name>wml</SPAN><SPAN class=tag>></span><span>″); </span> </li> <li class=""> <span></span><span class="tag">?></span><span> </span> </li> </ol>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.
