thinkphp build mobile version of the website _php tutorial

Source: Internet
Author: User
The function in the code is is_mobile from the Internet and is very well written. The portal file defines the App_path and app_name by judging the terminal type, thus performing different groupings. The effect I want to achieve is that both PC and mobile are accessed with top-level domain names. Of course, if you want to implement similar to wap.xxx.com in the mobile phone, this method is not possible, this is the thinkphp multi-domain deployment problem, see the TP manual.
Using the thinkphp framework to develop a small site quickly is still very convenient, as this site. Root NET also made a mobile phone website, mobile browser input site domain name www.icaigen.com view effect.

The following is just about implementing platform judgments in Thinkphp's front-end boot page index.php file to load different groupings (or projects).

Determine if the cell phone function is_mobile () {$user _agent = $_server[' http_user_agent ']; $mobile _agents = Array ("240x320", "Acer", "Acoon", "acs-", "Abacho", "Ahong", "Airness", "Alcatel", "Amoi", "Android", " Anywhereyougo.com "," applewebkit/525 "," applewebkit/532 "," Asus "," Audio "," Au-mic "," Avantogo "," Becker "," BenQ "," Bilbo "," Bird "," BlackBerry "," blazer "," Bleu "," cdm-"," Compal "," Coolpad "," Danger "," Dbtel "," Dopod "," Elaine "," Eric ", "Etouch", "Fly", "Fly_", "fly-", "Go.web", "goodaccess", "Gradiente", "Grundig", "Haier", "Hedy", "Hitachi", "HTC", " Huawei "," Hutchison "," Inno "," ipad "," iPAQ "," ipod "," Jbrowser "," KDDI "," kgt "," KWC "," Lenovo "," LG "," Lg2 "," Lg3 "," LG4 ", "Lg5", "Lg7", "Lg8", "Lg9", "lg-", "lge-", "Lge9", "Longcos", "Maemo", "Mercator", "Meridian", "Micromax", "MIDP", "Mini", " Mitsu "," MMM "," MMP "," Mobi "," mot-"," Moto "," nec-"," NetFront "," Newgen "," Nexian "," Nf-browser "," Nintendo "," Nitro "," Nokia "," Nook "," Novarra "," Obigo "," Palm "," Panasonic "," Pantech "," Philips "," Phone "," pg-"," PlayStation "," Pocket "," Pt-"," qc-"," Qtek "," Rover "," Sagem "," sama "," Samu ","Sanyo", "Samsung", "sch-", "Scooter", "sec-", "Sendo", "sgh-", "Sharp", "Siemens", "sie-", "SoftBank", "Sony", "Spice", " Sprint "," SPV "," Symbian "," tablet "," Talkabout "," tcl-"," Teleca "," Telit "," Tianyu "," tim-"," Toshiba "," TSM "," Up.browser "," Utec "," Utstar "," Verykool "," Virgin "," vk-"," Voda "," Voxtel "," VX "," WAP "," Wellco "," Wig Browser "," Wii ","    Windows CE "," wireless "," XDA "," Xde "," ZTE ");    $is _mobile = false;            foreach ($mobile _agents as $device) {if (Stristr ($user _agent, $device)) {$is _mobile = true;        Break }} return $is _mobile;}    Define (' Think_path ', './core/'); if (Is_mobile ()) {//Jump to Wap packet define (' App_name ', ' wap '); Define (' App_path ', './wap/');}    else{define (' app_name ', ' Home ');           Define (' App_path ', './home/'); }define (' App_debug ', false); require Think_path. ' core.php ';
The function in the code is is_mobile from the Internet and is very well written. The portal file defines the App_path and app_name by judging the terminal type, thus performing different groupings.

The effect I want to achieve is that both PC and mobile are accessed with top-level domain names. Of course, if you want to implement similar to wap.xxx.com in the mobile phone, this method is not possible, this is the thinkphp multi-domain deployment problem, see the TP manual.

The portal file is defined, and then the code for the mobile website can be developed under a WAP grouping (or project). Because it is the mobile version of the website, resolution, image compression, page size, etc. are naked issues. I also contact mobile website construction Not a few days, will not show off. It can be clear that the PC-side website is not the main features on the mobile site can be cut off, such as blog popular articles, random articles, comments list, various pendants and so on.

http://www.bkjia.com/PHPjc/446942.html www.bkjia.com true http://www.bkjia.com/PHPjc/446942.html techarticle the function in the code is is_mobile from the Internet and is very well written. The portal file defines the App_path and app_name by judging the terminal type, thus performing different groupings. The effect I want to achieve is ...

  • 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.