本文介紹了PHP - 檢查頁面是否在移動(dòng)或桌面瀏覽器上運(yùn)行的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
限時(shí)送ChatGPT賬號(hào)..
在我的 PHP 頁面中,根據(jù)頁面是在移動(dòng)瀏覽器還是桌面瀏覽器下運(yùn)行,我應(yīng)該顯示兩種不同的文本內(nèi)容.有沒有辦法在 PHP 中執(zhí)行這種控制?
In my PHP page I should display two different text contents according to whether the page run under mobile or desktop browser. Is there a way to perform this control in PHP?
推薦答案
這里有一個(gè)非常好的 PHP 庫用于檢測(cè)移動(dòng)客戶端:http://mobiledetect.net
There is a very nice PHP library for detecting mobile clients here: http://mobiledetect.net
使用它很容易只顯示移動(dòng)設(shè)備的內(nèi)容:
Using that it's quite easy to only display content for a mobile:
include 'Mobile_Detect.php';
$detect = new Mobile_Detect();
// Check for any mobile device.
if ($detect->isMobile()){
// mobile content
}
else {
// other content for desktops
}
這篇關(guān)于PHP - 檢查頁面是否在移動(dòng)或桌面瀏覽器上運(yùn)行的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!