Selected from slamdunk3's Blog
1. File format The first problem you must encounter is the file format. When doing web development, everyone uses html or xhtml. When it comes to wap development, you have to use wml. What is wml? You can check more detailed information. I only mentioned it briefly here. In my opinion, wml is similar to xml and has a very strict format. When making wap pages, you have to use wml for display.
The syntax of wml is very Simple, when using PHP for dynamic output, you must send a header message to indicate that this page is wml, not some other *ml.
header("Content-type: text/vnd.wap.wml; charset=" gb2312"");
?>
The character set used here is gb2312. There is no problem on the mobile platform, but it will not work on the China Unicom platform. UTF-8 must be used. In order to be more versatile, it is safer to use UTF-8. That is
header("Content-type: text/vnd.wap.wml; charset="utf-8"");
?>
2. Encoding
As mentioned above, the character set should all use utf-8. This is a character set that accommodates multiple languages. A Chinese character occupies two bytes, and utf-8 occupies 4 bytes, so it can accommodate The amount of information is greater. Chinese characters written on the mobile phone may be a bunch of garbled characters after the page code is converted to utf-8 when opened later. Therefore, when making comments, use English comments as much as possible to avoid unnecessary trouble.
I willnot be able to understand it in the future. Tools such as editplus and ultraedit can convert the internal code of files.
3. It
is really difficult to adapt to the world's major mobile phone manufacturers. The mobile phones developed are all kinds of weird and can support a variety of formats. For example, ringtones, some can Supports 16, 32, 48 chords, supports mid, wmv, some do not fully support it; some support gif, png, bmp, and some do not fully support it. Although this increases the grade and cost of mobile phones, but But it’s hard for brothers who are engaged in mobile phone development. Because it is inevitable to make a match for the pictures, ringtones and other multimedia information that the mobile phone can support. This matching process is generally called mobile phone adaptation.
To do mobile phone adaptation, we generally need the following information.
1) A detailed mobile phone adaptation data sheet, which should describe in detail the ringtones and picture formats that the mobile phone can support, as well as mobile phone model and other information.
2) To correctly obtain the UA of the mobile phone, what is UA is (user agent), which is actually the user’s mobile phone information.
Only with the above can we make adaptations. Here is one I wrote on wap The classes used in development can be used to obtain mobile phone numbers and mobile phone UA.
/**
* Class name: mobile
* Description: Mobile phone information
* Others: Written by chance
*/
class mobile
{
/**
* Function name: getPhoneNumber
* Function: Get mobile phone number
* Input parameters: none
* Function return value: Return number if successful, false if failed
* Other instructions: instructions
*/
function getPhoneNumber()
{
if (isset($_SERVER['HTTP_X_NETWORK_INFO']))
{
$str1 = $_SERVER['HTTP_X_NETWORK_INFO'];
$getstr1 = preg_replace('/(.*,)(11[d])(,.*)/i','',$str1);
Return $getstr1;
}
elseif (isset($_SERVER['HTTP_X_UP_CALLING_LINE_ID']))
{
$getstr2 = $_SERVER['HTTP_X_UP_CALLING_LINE_ID'];
Return $getstr2;
}
elseif (isset($_SERVER['HTTP_X_UP_SUBNO']))
{
$str3 = $_SERVER['HTTP_X_UP_SUBNO'];
$getstr3 = preg_replace('/(.*)(11[d])(.*)/i','',$str3);
Return $getstr3;
}
elseif (isset($_SERVER['DEVICEID']))
{
Return $_SERVER['DEVICEID'];
}
else
{
Return false;
}
}
/**
* Function name: getHttpHeader
* Function: Get header information
* Input parameters: none
* Function return value: Return number if successful, false if failed
* Other instructions: instructions
*/
function getHttpHeader()
{
$str = '';
foreach ($_SERVER as $key=>$val)
{
$gstr = str_replace("&","&",$val);
$str.= "$key -> ".$gstr."rn";
}
Return $str;
}
/**
* Function name: getUA
* Function: Get UA
* Input parameters: none
* Function return value: Return number if successful, false if failed
* Other instructions: instructions
*/
function getUA()
{
if (isset($_SERVER['HTTP_USER_AGENT']))
{
Return $_SERVER['HTTP_USER_AGENT'];
}
else
{
Return false;
}
}
/**
* Function name: getPhoneType
* Function: Get the mobile phone type
* Input parameters: none
* Function return value: string if successful, false if failed
* Other instructions: instructions
*/
function getPhoneType()
{
$ua = $this->getUA();
if($ua!=false)
{
$str = explode(' ',$ua);
Return $str[0];
}
else
{
Return false;
}
}
/**
* Function name: isOpera
* Function: Determine whether it is opera
* Input parameters: none www.knowsky.com
* Function return value: string if successful, false if failed
* Other instructions: instructions
*/
function isOpera()
{
$uainfo = $this->getUA();
if (preg_match('/.*Opera.*/i',$uainfo))
{
Return true;
}
else
{
Return false;
}
}
/**
* Function name: isM3gate
* Function: Determine whether it is m3gate
* Input parameters: none
* Function return value: string if successful, false if failed
* Other instructions: instructions
*/
function isM3gate()
{
$uainfo = $this->getUA();
if (preg_match('/M3Gate/i',$uainfo))
{
Return true;
}
else
{
Return false;
}
}
/**
* Function name: getHttpAccept
* Function: Get HA
* Input parameters: none
* Function return value: string if successful, false if failed
* Other instructions: instructions
*/
function getHttpAccept()
{
if (isset($_SERVER['HTTP_ACCEPT']))
{
Return $_SERVER['HTTP_ACCEPT'];
}
else
{
Return false;
}
}
/**
* Function name: getIP
* Function: Get mobile phone IP
* Input parameters: none
* Function return value: string returned successfully
* Other instructions: instructions
*/
function getIP()
{
$ip=getenv('REMOTE_ADDR');
$ip_ = getenv('HTTP_X_FORWARDED_FOR');
if (($ip_ != "") && ($ip_ != "unknown"))
{
$ip=$ip_;
}
return $ip;
}
}
?>
4. Page design
When developing wap, the wap page is very simple. It can't be simpler than html. In wap1.0, there are no messy things like tables. All tags are It is written in a tag called card. It can be used for segmentation. So it is easy to create pages.
5. Simulator
For wap development, it is inevitable to use various simulators for testing. The better one is m3gate. , openwave, opera, and one called winwap. It is best not to use it for testing. Its compatibility is so good that even if there are errors on the page, they can be ignored. The test is the same as using a browser to test a web page. , just enter the URL. There is nothing easier than this.
6. Notes
1) Spaces, especially when defining DTD,
echo "";
?>
If there are missing spaces somewhere in it, you will suffer. When I was writing, I used page rearrangement to remove some spaces. It took me two days to find the error. Please don’t follow my example. Follow the example.
2) Tags, if the tags are not paired, an error will be prompted. Just pay attention, it is easy to correct.