Wml,apache, and introduction to PHP _php Basics

Source: Internet
Author: User
Tags php compiler
In the company's website, I found that I need a wireless to receive my email, stock information and so on. Instead of paying people to get the information I wanted, I decided to develop a wireless web site. Such information is fine on the internet, but it is scattered hard to collect. I need to be able to execute PHP, access the database, and I need PHP to do another function for me. This article covers the basics of WML, how to build your Apache Server and PHP. These basics allow you to build your environment and learn about your future applications.
 

Demand
You want to have some experience with Apache Web Server, Php and HTML. For the system's requirements, I'm using the Apache 1.3.9, PhP3, and Red Hat Linux 6.0来 demonstrations. I haven't encountered any problems running Apache on Windows, and PHP3 or PHP4.

In this article, I'll guide you through the field of engagement: WML introduction, setting up wireless appications on Apache, and building your first wml/php Web page. Most of the information can be collected from the Internet.

Introduction to WML
WML represents the wireless annotation language. A WAP phone or similar device is used as a Web page written in WML. WML is based on its syntax and scrictness similar to XML. Anyone who has used HTML will have no problem learning WML. Many tags and attributes are the same, and there are not many tags. WML allows program developers to develop dynamic content, although for this article we will use PHP as the dynamic language.

WML Foundation
In WML you can use many sub pages (called "cards") in a WML page (called "Deck"). Each WML card acts as if it were displayed in a Web page. The following will be examples of our. WML pages. On my Server, I store this file in ~/wireless/home.wml.

<wml>
<card id= ' home ' > <p> my First Test page </p>
</card>
</wml>

Unlike HTML, if you don't colse tags, such as <wml> </wml&gt, your code will not be correct. This example will produce a simple test message "My first test page" on any wireless device.

Set Apache
OK, now the interesting part. For Apache to catch a wireless device to visit your server, you need to build your httpd.conf (my file is located in/etc/httpd/conf/) file, I use PHP3 so all the changes will be recorded. Before you start, you can back up your httpd.conf file, just in case:

Step 1: First, we need the AddType feature to add a new MIME type. You need to go to your PHP-defined Script. Looks like the following:

<ifmodule mod_php3.c>
AddType application/x-httpd-php3. php3. php. phtml

AddType Application/x-httpd-php3-source. Phps

</IfModule>

To read:

 

<ifmodule mod_php3.c>
AddType application/x-httpd-php3. php3. php. phtml. WML

AddType Application/x-httpd-php3-source. Phps
</IfModule>

This will be used with PHP compiler on all. WML pages.

Step 2: Remove mark (uncomment) Apache Load module and ADD module

Change:


#LoadModule Rewrite_module modules/mod_rewrite.so

#AddModule mod_rewrite.c
 

Yes:

LoadModule Rewrite_module modules/mod_rewrite.so

Addmodule mod_rewrite.c


Step 3: Use Apache mod_rewrite module (1.2+ version only). With this, you can instantly rewite requested URLs (when conditions are met). You need to put this piece on the bottom of the page.

 

Rewriteengine on

# Catch Most WAP browsers

Rewritecond%{http_accept} TEXT/VND\.WAP\.WML [OR]

# Winwap, Wapjag

Rewritecond%{http_user_agent} WAP [OR]

#Nokia emulators (SDK)

Rewritecond%{http_user_agent} 7110

# Rewrite to where your wireless the page is located

Rewriterule ^[\./] (. *) $/HOME/MYDIRECTORY/WIRELESS/HOME.WML [L]


Now you want to restart Apache server.

 

Generate your first wireless wml/php Web page
Ok, now that we have everything, let's build the first page. In order to function properly, you need to transmit the correct header information.
<?php

# Send the header information<br>
Header ("CONTENT-TYPE:TEXT/VND.WAP.WML");

?>

# put in the WML code
<wml>

<card id= ' Home ' >

<p>

My I-test page

<p>
</card>
</wml>

You've just completed your first "simple" wireless Web page. Now, let's try harder to do something harder.

You need to check your WAP-compatible site device. I use the Phone.com Software Development Kit, which contains up. Simulator, you can check my wireless Web page. Choose different phones and look at their wireless web pages as they look when they pass through different devices.


More information on:

Http://updev.phone.com
http://www.wapforum.org
Http://www.wap.com
Http://www.waplinks.com

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.