導航:首頁 > 電腦視頻 > php手機電腦

php手機電腦

發布時間:2023-01-22 12:05:21

A. PHP如何識別是電腦端或手機移動端訪問網站

用css來判斷當前頁面的寬度和高度,現在pc的解析度最低都在1200*768以上,iPad pro的寬度為1024px,當寬度大於1100px以上,都可以認為當前訪問端為pc,一般iPad的寬度為768px,iPhone X的寬度為375px;所以當寬度低於800以下的,都視為手機移動端,現在的pc和手機自適應頁面都是按照這個來區分的。

B. php判斷手機電腦並且進行跳轉

<?
$wap="手機地址";
$pc="pc地址";
ww($wap,$pc);
function ww($wap,$pc){
if(preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])){header("Location: $wap");
exit;
}else{header("Location: $pc");
exit;}
}
?>

C. PHP判斷客戶端是電腦還是手機

php判斷客戶端是手機的代碼,版權歸原作者,我只是搬運工。
function isMobile()
{
// 如果有HTTP_X_WAP_PROFILE則一定是移動設備
if (isset ($_SERVER['HTTP_X_WAP_PROFILE']))
{
return true;
}
// 如果via信息含有wap則一定是移動設備,部分服務商會屏蔽該信息
if (isset ($_SERVER['HTTP_VIA']))
{
// 找不到為flase,否則為true
return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false;
}
// 腦殘法,判斷手機發送的客戶端標志,兼容性有待提高
if (isset ($_SERVER['HTTP_USER_AGENT']))
{
$clientkeywords = array ('nokia',
'sony',
'ericsson',
'mot',
'samsung',
'htc',
'sgh',
'lg',
'sharp',
'sie-',
'philips',
'panasonic',
'alcatel',
'lenovo',
'iphone',
'ipod',
'blackberry',
'meizu',
'android',
'netfront',
'symbian',
'ucweb',
'windowsce',
'palm',
'operamini',
'operamobi',
'openwave',
'nexusone',
'cldc',
'midp',
'wap',
'mobile'
);
// 從HTTP_USER_AGENT中查找手機瀏覽器的關鍵字
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT'])))
{
return true;
}
}
// 協議法,因為有可能不準確,放到最後判斷
if (isset ($_SERVER['HTTP_ACCEPT']))
{
// 如果只支持wml並且不支持html那一定是移動設備
// 如果支持wml和html但是wml在html之前則是移動設備
if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'textml') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'textml'))))
{
return true;
}
}
return false;
}

D. PHP怎樣識別手機與電腦的不同訪問

這個可以使用js來判斷一下UA就可以了。。

下面是一個手機訪問跳轉到手機版頁面的例子


(functionbrowserRedirect(){
varsUserAgent=navigator.userAgent.toLowerCase();
varbIsIpad=sUserAgent.match(/ipad/i)=='ipad';
varbIsIphone=sUserAgent.match(/iphoneos/i)=='iphoneos';
varbIsMidp=sUserAgent.match(/midp/i)=='midp';
varbIsUc7=sUserAgent.match(/rv:1.2.3.4/i)=='rv:1.2.3.4';
varbIsUc=sUserAgent.match(/ucweb/i)=='web';
varbIsCE=sUserAgent.match(/windowsce/i)=='windowsce';
varbIsWM=sUserAgent.match(/windowsmobile/i)=='windowsmobile';
varbIsAndroid=sUserAgent.match(/android/i)=='android';
if(bIsIpad||bIsIphone||bIsMidp||bIsUc7||bIsUc||bIsCE||bIsWM||bIsAndroid){
window.location.href='/wap/';
}
})();

E. php文件手機上怎麼打開

php文件屬於腳本語言文件,在正確瀏覽和使用他需要有相應的解析伺服器,現在主流是lamp架構或者lnmp架構的伺服器打開並解析php文件
在手機上打開你可以直接用手機里邊的文本編輯器打開就可以了,不過這樣打開你看到的會是php代碼,對於不懂編程的人來說看不懂,沒有什麼用

F. php程序有電腦版和手機版,怎讓手機訪問電腦版時自動識別是手機訪問跳到手機版去。電腦訪問手機版時自

你需要做一個手機頁,使用判斷語句,因為瀏覽器有一個自己的標示,如果是手機瀏覽器就跳到M頁,也就是手機頁面,這個你需要先在前端CSS做一個手機的匹配頁面,然後在將它用PHP實例化;還有你必須在頁面底部增加一個可切換,切換為電腦版,手機版的連接;

G. PHP代碼,怎麼設置根據電腦和手機顯示不同內容

構造一個判斷函數,匹配列出的agent就行,如果為真就輸出數字5或者之類的數據嘛,反之就輸出其他的,不會的話再問額解決

H. php如何判斷用戶通過手機wap訪問還是電腦直接訪問

PHP通過內置全局變數$_SERVER['HTTP_USER_AGENT']來獲取用戶信息,包括瀏覽器信息,操作系統等;判斷是否是手機還是電腦終端訪問,只需判斷他的$_SERVER['HTTP_USER_AGENT']信息是否存在手機終端類型即可。示例如下:
<?php
//1.獲取用戶瀏覽器信息 等;
$user_agent = $_SERVER['HTTP_USER_AGENT'];

//2.列舉常用手機終端類型
$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","iphone","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");

foreach ($mobile_agents as $device) {
if (stristr($user_agent, $device)) {
//手機訪問
$is_mobile = true;
break;
}
}
//判斷手機標識是否為真
if($is_mobile){
echo "手機訪問!";
}else{
echo "電腦訪問!";
}

?>

回答不容易,希望能幫到您,滿意請幫忙採納一下,謝謝 !

閱讀全文

與php手機電腦相關的資料

熱點內容
電腦上怎麼下載班智達的軟體 瀏覽:1115
無痕跡消除圖片軟體 瀏覽:683
免費小票軟體 瀏覽:918
華為在哪裡設置軟體停止運行 瀏覽:929
用電腦鍵盤調節聲音大小 瀏覽:1228
自動刷軟體賺錢 瀏覽:1229
古裝連續劇免費版 瀏覽:1381
工免費漫畫 瀏覽:1121
手機軟體專門儲存文件 瀏覽:1477
uos如何用命令安裝軟體 瀏覽:1273
有線耳機插電腦麥克風 瀏覽:625
侏羅紀世界3在線觀看完整免費 瀏覽:965
單個軟體怎麼設置名稱 瀏覽:688
鳳凰網電腦版下載視頻怎麼下載視頻怎麼下載 瀏覽:1351
明白之後如何免費獲得無人機 瀏覽:800
如何解禁軟體菜單 瀏覽:807
副路由器連接電腦視頻 瀏覽:1323
內置wifi電視如何裝軟體 瀏覽:1062
手機換零免費雪碧 瀏覽:1557
國行蘋果如何下載美版軟體 瀏覽:1173