中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

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

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

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

宁德市| 若尔盖县| 荆州市| 库车县| 定南县| 铜山县| 滦南县| 琼结县| 大连市| 罗甸县| 商都县| 浦县| 客服| 浮梁县| 罗平县| 前郭尔| 靖安县| 东兴市| 会东县| 承德市| 灵石县| 浙江省| 兰溪市| 获嘉县| 嘉定区| 济阳县| 新邵县| 安庆市| 赤城县| 沙田区| 化州市| 南陵县| 社会| 阳江市| 黄浦区| 武山县| 延吉市| 牙克石市| 勐海县| 呼和浩特市| 巫山县|