The development of WAP is inseparable from its WWW heritage. After all, the entire WAP protocol was formulated with reference to the WWW model and used many Internet standards and technologies as much as possible. For example, the WML language was born out of HTML and XML, and WMLScript was derived from traditional Scripting languages are also very similar. Indeed, although WAP is a new term, it is inseparably integrated with the traditional international Internet, both structurally and technically.
It is mentioned in the WAP protocol that the markup language used by WAP pages is WML. When higher-level operations are required, such as using certain resources of the terminal, you can use the WMLScript scripting language. These two languages are very simple, and you can even use To describe it simply, they are almost incapable of operating databases. This "flaw" is incompatible with WAP's broad business and application prospects, but we are not powerless. Due to the integration of WAP and WWW, we can still use WWW technology. and resources to solve database access problems, because after all, most databases are still within the wired network.
What is the most popular combination of web programming language and database at present? I believe many people will say the names "PHP" and "MySQL". They belong to the category of WWW or wired Internet. They are famous for their ease of use and powerful functions. So can they serve WAP? The answer is yes. People who are not familiar with WAP or PHP may be a little confused. After all, in the traditional sense, PHP provides WWW content and services. Are they "compatible" with WAP?
A Rough
Introduction to PHP After reading the introduction to WAP, everyone should begin to gradually understand why PHP can still serve WAP. PHP is different from HTML, WML, Javascript, and Java. It runs on the server side, while Javascript, Java, etc. all run on the browser side. Compared with WAP, WMLScript runs on the client side. However, the above languages All can be easily combined with PHP.
PHP has great flexibility. In the WWW, it can generate any HTML code required, even Javascript code. Similarly, in WAP, we can still use the dynamic and flexible characteristics of PHP to generate arbitrary WML code, so that PHP can naturally serve WAP.
The reason why PHP is used to provide WAP services is not only its flexible features, but also because PHP can easily use databases. Users can use PHP to access Oracle, Sybase, MS SQL, MySQL, dBase, Informix and other databases that support ODBC standards, which just caters to the needs of WAP business.
In practice, it is generally necessary to create a PHP file. When the user sends a request to the server to browse the PHP file, the server will generate the corresponding HTML or WML content based on the code in the file and send it to the browser or WAP terminal.
If you want to get information about PHP, you can go to http://www.php.com .
PHP-WML
PHP's system platform, working method, and installation method are not within the scope of this article. After all, our focus is on how PHP cooperates with WAP. Generally speaking, in order to make PHP work, we need a web server with a PHP module, or a server that supports PHP. Apache is the most popular web server in the world. In addition, we also need to install PHP software and such as MySQL. Database, specific content can be found in relevant books or websites. Below we discuss how to let PHP generate WML code.
In the WWW, the first line of content generated by PHP is often: content-type: text/html
However, WAP terminals cannot read such titles. The unit for WAP terminals to download from the server is Deck, and the unit for browsing is Card. Generally, a Deck constitutes a WML file. Then, when serving WAP, the PHP file often needs to contain the following code:
header("Content-type:text/vnd.wap.wml");
echo "<xml version="1.01">n"
echo"<! DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"" http://www.wapforum.org//DTD//wml_1.1.xml ">n" ;
The above three lines of code generate the file header of the WML file (Deck), so that the WAP terminal can identify whether the downloaded Deck is in WML format, and then display the remaining Deck content.
Below is the simplest Deck, which displays "Hello World" on the WAP terminal.
<?xml version="1.0" encoding="ISO-8859-1"?> <! DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" " http://www.wapforum.org// DTD//wml_1.1.xml ">
</xml>
<!--Nokia Parser Info:Phone = Nokia 7110; Height = 90; Width = 130; CurrentDeckSize = 38; MaxDeckSize = 1600; CardsOnEachLine = 5; CardsVerticalGap = 30-->
</card id="card1" ordered="true" newcontext="false">
<p align="left">
Hello World
</p>
</card>
</wml>
The corresponding PHP files we created are as follows:
<?php
header("Content-type:text/vnd.wap.wml");
echo "<?xml version="1.0">n";
echo "<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" " http://www.wapforum.org//DTD//wml_1.1.xml ">n" ;
echo "n";
echo "<!--Nokia Parser Info: Phone = Nokia 7110; Height = 90; Width = 130; CurrentDeckSize = 38; MaxDeckSize = 1600; CardsOnEachLine = 5; CardsVerticalGap = 30-->n";
echo "<card id="card1" ordered="true" newcontext="false"> ";
echo "<p align="left">n";
echo "Hello World";
echo "</p>";
echo "</card>";
echo "</wml>";
?>
We can save the file as index.php3. When the WAP terminal browses the website, the Web server will automatically generate the WML content listed above based on the content of index.php3 and send it to the gateway for processing. After the WAP terminal receives the Deck, it will display the words "Hello World" on the display.
The above is the simplest application of PHP in WAP. It simply generates several lines of WML code and does not involve database access. In fact, the powerful functions of PHP can provide a wealth of services for WAP, and the most worthy of exploration is its powerful database support, which will be discussed in future articles.