Home Backend Development PHP Tutorial PHP编程在WAP开发中的应用_PHP

PHP编程在WAP开发中的应用_PHP

Jun 01, 2016 pm 12:43 PM
Virus cybercafe Information software

我们可以使用PHP来编写WAP程序,比如开发动态的WML页面,不过条件是需要将输出的标签或语句限制在WAP微型浏览器可接受的范围之内。而且,PHP 还可以在一个HTML(及HDML)文件中编写出既适合于HTML(及HDML),也适合于WML的内容。PHP的源代码对于WAP客户端来说是不可见的,所以我们可以针对HTML浏览器输出HTML页面,而针对WAP浏览器输出HDML页面或WML页面。

11.3.1 基本规则

以WML为例,使用PHP编写WML程序的基本规则如下:

(1) 使用“”和“?>”来包含PHP编写的WML程序行,格式为:

……(程序行);

?>

(2) 程序行语句均以分号( ; )结尾,这是与ASP编写WML程序不同的地方。

(3) 使用PHP的header关键字来声明WML的文件类型,基本格式为:

header("Content-type: text/vnd.wap.wml");

上述格式是专为WAP浏览器识别而采取的书写格式。如果开发中用户想使用普通的浏览器,如IE浏览器来测试程序效果,则可在该语句的前面加上双斜线(//),格式为:

// header("Content-type: text/vnd.wap.wml");

这样,基于PC的浏览器将忽略程序中无法理解的WML标签,这时当前的程序实际上成为了HTML页面。当想在WAP设备或者模拟器上测试的时候,只需要去掉“//”,当前页面就会自动变成WML页面。

(4) 其他WML标签和语句行一律使用PHP的echo关键字来声明,每个WML行的后面加上换行符“\n”(根据需要,也可加多个)。其基本格式为:

echo("……(WML标签和语句行)\n");

例如,下面的语句就是PHP编写WML语句行的典型例子:

echo("\n");

而且,echo语句中的“WML标签和语句行”可以连写,以节省程序代码行。例如,下面的一行语句就连写了WML的3行标签语句:

echo ("

");

(5) 声明脚本语言。这是对PHP编程的继承,向编译器声明当前程序采用的脚本语言为PHP,格式为:

不过这一句可以省略,因为编译器能够自动识别PHP的脚本程序。

(6) 文件最后保存时采用的扩展名为“.php”或“.php3”,而不是“.wml”等扩展名。

根据上述规则,我们可以用PHP编写出WML页面的文件头,并让程序在WAP浏览器中显示“Hello, World!”,代码如下:

以下为引用的内容:

header("Content-type: text/vnd.wap.wml");

echo("\n");

echo(""-//WAPFORUM//DTD WML 1.1//EN\" \"http://www. wapforum.org/DTD/wml_1.1.xml\">\n\n");

?>

echo ("

\n");

echo ("Hello, World!\n");

echo ("

\n");

?>

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What software is bonjour and can it be uninstalled? What software is bonjour and can it be uninstalled? Feb 20, 2024 am 09:33 AM

Title: Explore the Bonjour software and how to uninstall it Abstract: This article will introduce the functions, scope of use and how to uninstall the Bonjour software. At the same time, it will also be explained how to use other tools to replace Bonjour to meet the needs of users. Introduction: Bonjour is a common software in the field of computer and network technology. Although this may be unfamiliar to some users, it can be very useful in some specific situations. If you happen to have Bonjour software installed but now want to uninstall it, then

What to do if WPS Office cannot open the PPT file - What to do if WPS Office cannot open the PPT file What to do if WPS Office cannot open the PPT file - What to do if WPS Office cannot open the PPT file Mar 04, 2024 am 11:40 AM

Recently, many friends have asked me what to do if WPSOffice cannot open PPT files. Next, let us learn how to solve the problem of WPSOffice not being able to open PPT files. I hope it can help everyone. 1. First open WPSOffice and enter the homepage, as shown in the figure below. 2. Then enter the keyword "document repair" in the search bar above, and then click to open the document repair tool, as shown in the figure below. 3. Then import the PPT file for repair, as shown in the figure below.

What software is crystaldiskmark? -How to use crystaldiskmark? What software is crystaldiskmark? -How to use crystaldiskmark? Mar 18, 2024 pm 02:58 PM

CrystalDiskMark is a small HDD benchmark tool for hard drives that quickly measures sequential and random read/write speeds. Next, let the editor introduce CrystalDiskMark to you and how to use crystaldiskmark~ 1. Introduction to CrystalDiskMark CrystalDiskMark is a widely used disk performance testing tool used to evaluate the read and write speed and performance of mechanical hard drives and solid-state drives (SSD). Random I/O performance. It is a free Windows application and provides a user-friendly interface and various test modes to evaluate different aspects of hard drive performance and is widely used in hardware reviews

CrystalDiskinfo usage tutorial-What software is CrystalDiskinfo? CrystalDiskinfo usage tutorial-What software is CrystalDiskinfo? Mar 18, 2024 pm 04:50 PM

CrystalDiskInfo is a software used to check computer hardware devices. In this software, we can check our own computer hardware, such as reading speed, transmission mode, interface, etc.! So in addition to these functions, how to use CrystalDiskInfo and what exactly is CrystalDiskInfo? Let me sort it out for you! 1. The Origin of CrystalDiskInfo As one of the three major components of a computer host, a solid-state drive is the storage medium of a computer and is responsible for computer data storage. A good solid-state drive can speed up file reading and affect consumer experience. When consumers receive new devices, they can use third-party software or other SSDs to

How to set the keyboard increment in Adobe Illustrator CS6 - How to set the keyboard increment in Adobe Illustrator CS6 How to set the keyboard increment in Adobe Illustrator CS6 - How to set the keyboard increment in Adobe Illustrator CS6 Mar 04, 2024 pm 06:04 PM

Many users are using the Adobe Illustrator CS6 software in their offices, so do you know how to set the keyboard increment in Adobe Illustrator CS6? Then, the editor will bring you the method of setting the keyboard increment in Adobe Illustrator CS6. Interested users can take a look below. Step 1: Start Adobe Illustrator CS6 software, as shown in the figure below. Step 2: In the menu bar, click the [Edit] → [Preferences] → [General] command in sequence. Step 3: The [Keyboard Increment] dialog box pops up, enter the required number in the [Keyboard Increment] text box, and finally click the [OK] button. Step 4: Use the shortcut key [Ctrl]

What kind of software is bonjour? Is it useful? What kind of software is bonjour? Is it useful? Feb 22, 2024 pm 08:39 PM

Bonjour is a network protocol and software launched by Apple for discovering and configuring network services within a local area network. Its main role is to automatically discover and communicate between devices connected in the same network. Bonjour was first introduced in the MacOSX10.2 version in 2002, and is now installed and enabled by default in Apple's operating system. Since then, Apple has opened up Bonjour's technology to other manufacturers, so many other operating systems and devices can also support Bonjour.

How to resolve an incompatible software attempt to load with Edge? How to resolve an incompatible software attempt to load with Edge? Mar 15, 2024 pm 01:34 PM

When we use the Edge browser, sometimes incompatible software attempts to be loaded together, so what is going on? Let this site carefully introduce to users how to solve the problem of trying to load incompatible software with Edge. How to solve an incompatible software trying to load with Edge Solution 1: Search IE in the start menu and access it directly with IE. Solution 2: Note: Modifying the registry may cause system failure, so operate with caution. Modify registry parameters. 1. Enter regedit during operation. 2. Find the path\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Micros

How to completely remove viruses from mobile phones Recommended methods to deal with viruses in mobile phones How to completely remove viruses from mobile phones Recommended methods to deal with viruses in mobile phones Feb 29, 2024 am 10:52 AM

After a mobile phone is infected with a certain Trojan virus, it cannot be detected and killed by anti-virus software. This principle is just like a computer infected with a stubborn virus. The virus can only be completely removed by formatting the C drive and reinstalling the system. , then I will explain how to completely clean the virus after the mobile phone is infected with a stubborn virus. Method 1: Open the phone and click "Settings" - "Other Settings" - "Restore Phone" to restore the phone to factory settings. Note: Before restoring factory settings, you must back up important data in the phone. The factory settings are equivalent to those of the computer. "It's the same as formatting and reinstalling the system". After the recovery, the data in the phone will be cleared. Method 2 (1) First turn off the phone, then press and hold the "power button" + "volume + button or volume - button" on the phone at the same time.

See all articles