The basic of WAP and PHP programming

Source: Internet
Author: User
Tags header install php mysql php file php and php programming php software
The development of WAP can not be separated from its www, after all, the whole WAP protocol is developed according to the WWW model, and as far as possible to follow the Internet's many standards and technologies, such as the WML language derived from HTML and xml,wmlscript and traditional scripting language is also very similar. Indeed, WAP is a term, but it is inextricably linked to the traditional internet, structurally and technically.
  
The markup language used to refer to WAP pages in the WAP protocol is WML, and when more advanced operations, such as the use of some of the terminal's resources, can be used, the WMLScript scripting language, which is simple, can even be described in terms of simplicity, especially with regard to the operation of the database, This "flaw" and WAP broad business and application prospects are incompatible, but we are not powerless, due to the integration of WAP and WWW, we can still use WWW technology and resources to solve the database access problem, because after all, most of the database is still in the wired network.
  
What is the most popular web programming language and database match at the moment? I believe many people will say "PHP" and "MySQL" these two names. They belong to the category of WWW or wired Internet, because of the use of convenient and powerful features and good reputation spread, then they can for WAP service? The answer is yes. Not familiar with WAP or PHP people may be a little puzzled, after all, in the traditional sense of PHP to provide the content and service of WWW, for WAP, they can be "compatible"?

PHP Rough Solution

Read the introduction of WAP, we should begin to understand why PHP can still be a WAP service. PHP is not the same as HTML, WML, Javascript, Java, it is running on the server side, and Javascript, Java, etc. are running on the browser side, relative to the Wap,wmlscript run on the client side, but, All of these languages can be easily combined with PHP.

PHP has great flexibility, and it can generate any HTML code or even JavaScript code that is required at www. Similarly, in WAP, we can still use PHP dynamic, flexible features, generate arbitrary WML code, so that PHP can naturally for WAP services.
  
PHP is used to provide WAP services, in addition to its flexible features, but also because PHP can easily use the database. Users can use PHP to access any database that supports ODBC standards, such as Oracle, Sybase, MS SQL, MySQL, DBase, Informix, and so on, which caters to the needs of WAP commerce.

In practice, the general need to build PHP files, when users to the server to browse the request for the PHP file, the server will be based on the code generated in the file corresponding HTML or WML content, and sent to the browser or WAP terminal.
To get information about PHP, you can go to http://www.php.com to view it.

Php-wml

PHP's system platform, working methods, installation methods, these are not in the scope of this article, after all, our focus is how PHP and WAP collaboration. In general, in order for PHP to work, we need a Web server with a PHP module, or a PHP-enabled server, Apache is the world's most popular Web server, and we also need to install PHP software and databases such as MySQL, Specific content can be consulted related books or websites. Here we discuss how to get PHP to generate WML code.
  
In www, PHP produces the first line of content is often: content-type:text/html
  
However, the WAP terminal is not read this title. WAP terminal from the server to download the unit is deck, browse the unit is card, a general deck on the composition of a WML file. Then, for WAP services, PHP files often need to include 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 produce the header of the WML file (Deck) so that the WAP terminal can recognize whether the downloaded Deck is in WML format and then display the remaining Deck content.
  
Here 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 have 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 this file as Index.php3, and when the WAP terminal browses the website, the Web server automatically generates the WML content as listed on the content of the INDEX.PHP3, and sends it to the gateway for processing. When the WAP terminal receives the deck, the word "Hello World" will be displayed on the display.
  
The above is about PHP in the simplest application of WAP, it simply produces a number of line WML code, and does not involve access to the database. In fact, PHP's powerful features can provide a rich service for WAP, and the most worthy of mining is its strong database support, these will be discussed in future articles.

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.