亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Thinkphp通過一個入口文件怎么區分移動端和PC端

發布時間:2021-06-29 14:25:24 來源:億速云 閱讀:199 作者:chen 欄目:開發技術

這篇文章主要介紹“Thinkphp通過一個入口文件怎么區分移動端和PC端”,在日常操作中,相信很多人在Thinkphp通過一個入口文件怎么區分移動端和PC端問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”Thinkphp通過一個入口文件怎么區分移動端和PC端”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

廢話不多說了,直接給大家貼代碼了,具體代碼如下所示:

<?php
// 檢測PHP環境
if(version_compare(PHP_VERSION,'5.3.0','<')) die('require PHP > 5.3.0 !');
// 開啟調試模式 建議開發階段開啟 部署階段注釋或者設為false
define('APP_DEBUG',True);
define('MULTI_MODULE', false);
// 獲取當前文件所在的目錄
define('DKSITE_TSDIR', dirname(__FILE__));
// 定義應用目錄
define('APP_PATH',DKSITE_TSDIR.'/Application/');
//
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)) { //stristr 查找訪客端信息是否在上述數組中,不存在即為PC端。 
      $is_mobile = true; 
      break; 
    } 
  } 
  return $is_mobile; 
}
//判斷
if(is_mobile()){
 echo '您當前是在:手機端'; 
  // 手機端模塊
 define('BIND_MODULE','Mobile');
}else{ 
 echo '您當前是在:pc端';
  // pc端前臺模塊
 define('BIND_MODULE','Home');      
} 
// 引入ThinkPHP入口文件
require dirname(__FILE__).'/ThinkPHP/ThinkPHP.php';

到此,關于“Thinkphp通過一個入口文件怎么區分移動端和PC端”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

湄潭县| 侯马市| 甘德县| 临高县| 阿尔山市| 嫩江县| 隆林| 汝城县| 朝阳县| 榆社县| 泸西县| 进贤县| 广河县| 泉州市| 德昌县| 肥西县| 普格县| 灵石县| 成武县| 左贡县| 汾西县| 大同县| 永清县| 海安县| 通州市| 兴安盟| 黑河市| 马鞍山市| 舟山市| 龙游县| 喀喇沁旗| 巴楚县| 镇雄县| 老河口市| 深圳市| 芜湖市| 承德市| 合水县| 平乐县| 通化市| 色达县|