I have made a few months of WAP development. I will briefly introduce some questions I have encountered in WAP development for everyone.
Update Description: The number 13 appearing in the class is wrong, and now it has been changed to 11. Mathematics is not learning, even the length of the mobile phone number is not clear, this will be lost.
[#M_ More .. | Hide .. | 1. The problem you want to encounter first is definitely the file format. When as a web development, everyone uses HTML or XHTML. When WAP is developed, it will be used. WML. What is WML? You can check more detailed information, I just mentioned slightly. In my opinion, WML is similar to XML, there is a very strict format, when I have a WAP page, I have to use WML. As a display.
WML's syntax is very simple. When using PHP as dynamic output, be sure to send a header information, indicating that this page is WML, not something else * ml.
[Code]
Header ("Content-Type: text / vnd.wap.wml; charset = /" gb2312 / ");?> [/ code]
The character set used here is GB2312, there is no problem on the mobile platform, but in the platform of Unicom, it is not possible to use UTF-8. In order to be more common, use UTF-8 more secure. That is
[Code]
Header ("Content-Type: text / vnd.wap.wml; charset = /" uTF-8 / ");?> [/ code]
2. Code
The character set should be used in the character set, which is a character set that accommodates a multi-language. A Chinese character is a double byte. UTF-8 accounts for 4 bytes, so it is covered by more information. The Chinese characters written on the phone, after turning the page to UTF-8, it may be a bunch of garbled, so everyone is as good as possible, and save it as much as possible. Efforts such as EditPlus, UltraEdit can be transferred to the file.
3. Adaptation
The world's mobile phone manufacturers are really sick, the development of mobile phones, can support the format is also a five-flowers, such as ringtone, some can support, 16, 32, 48 chords, support MID, WMV, some incomplete support; some Supports GIF, PNG, BMP, and some are not fully supported. Although this is a hand of mobile phone and cost, but he bites the brothers developed by mobile phones. Because inevitable, it is necessary to support mobile phones. Picture, ringtone and other multimedia information make a match, this matching process, we are generally called mobile phone adaptation. To make a mobile phone adapt, we generally have the following information.
1) A detailed mobile phone adaptation data sheet should be detailed in detail the ringtone, picture format, but also have information such as mobile phone models. 2) To properly obtain UA, what is UA, that is, User agent, actually the user's mobile phone information.
With the above Dongdong we can make advice. The following gives a class I wrote in WAP development, which can be used to take the mobile phone number, the mobile phone UA.
[Code]
/ *** Class Name: Mobile * Description: Mobile Information Class * Other: Casual Writing * / Class Mobile {/ *** Function Name: getPhoneNumber * Function: Take a mobile phone number * Enter parameters: none * function return value: success Return the number, failed to return false * Other instructions: Description * / Function getPhoneNumber () {if (isset ($ _ server ['http_x_network_info')) {$ str1 = $ _server ['http_x_network_info']; $ getStr1 = preg_replace ('/ (. *,) (,. *) / I ',' / 2 ', $ 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 ',' / 2 ', $ str3); return $ getStr3;} elseif (isset ($ _ server [' deviceid ')) {return $ _server [' DeviceID '] } else} / *** function name: getttpHeader * function function: head information * Enter parameters: none * function Return value: successful return number, failed to return false * Other instructions: Description * / Function gethtpheader () {$ str = ''; foreach ($ _SERVER AS $ Key => $ VAL) {$ GSTR = STR_REPLACE ("&", "&", $ VAL); $ Str. = "$ Key ->". $ GSTR. "/ r / n";} Return $ Str;}
/ *** Function Name: getua * Function: Take UA * Enter parameters: none * function Return Value: Successful return number, fail return false * Other instructions: Description * / Function getua () {if (isset ($ _ server [ 'Http_user_agent'])) {RETURN $ _SERVER ['http_user_agent'];} else {returnaf false;}}
/ *** Function Name: getPhoneType * Function function: get a mobile phone type * Enter parameters: none * function return value: successful return String, failed to return false * Other instructions: Description * / Function getPhoneType () {$ ua = $ THIS- > getua (); if ($ ua! = false) {$ str = evtern (', $ ua); return $ str [0];} else {return false;}}
/ *** Function Name: isopera * function function: Judgment is Opera * input parameters: none * function return value: success return String, failed to return false * Other instructions: Description * / Function isopera () {$ uinfo = $ THIS -> getua (); if (PREG_MATCH ('/.* Opera. * / i', $ uainfo)) {return true;} else {return false;}} / *** function name: ISM3GATE * function function: judgment Whether it is m3gate * input parameters: none * function return value: successful return String, failed to return false * Other instructions: Description * / Function ism3gate () {$ uainfo = $ this-> getua (); if (preg_match ('/ m3gate / i ', $ uainfo) {return true;} else {return false;}}
/ *** Function Name: getHttpAccept * Function Function: Get HA * Input Parameters: None * Function Return Value: Successful Return String, Failback Return False * Other Description: Description * / Function GethttpAccept () {ified ($ _ server [ 'Http_accept'])) {RETURN $ _SERVER ['http_accept'];} else {returnaf false;}}
/ *** Function Name: getip * function function: get a mobile phone IP * input parameter: none * function return value: success return string * Other instructions: Description * / function getip () {$ ip = getENV ('remote_addr'); $ ip_ = getenv ('http_x_forwarded_for'); if ($ IP_! = ") && ($ IP_! =" Unknown ")) {$ ip = $ ip _;} RETURN $ IP;}}?> [/ Code ]
4. Page design
When WAP is developed, the WAP page is very simple. It is simple to not be simpler than HTML. In WAP1.0, there is no table, a mess, a table, all the labels are written in a Card. The label can be used to segment. So doing the page is relaxed.
5. Simulator
WAP development is unable to use a wide variety of simulators to test, there is M3gate, Openwave, Opera, and a called WinWap, everyone is best not to use him to test, his compatibility is too good. Even if there is an error in the page, it can be ignored. When testing with the browser test the web page, enter the URL can be. No more easy thing than this.
6. Precautions
1) Space, especially when defining DTDs,
[Code]
echo "";?> [/ code]
In this place, if there is a few spaces, you have been there. After using the page rearrangement, put some spaces, I have to find a mistake in two days, I don't step to me. Rear dust.
2) Tags, if the label is not pair, will prompt the error, everyone pays attention to it, it is easy to correct.
The above is some of my experiences, written out for your reference, limited time, write more rush, have time to write a more detailed service ._m #]