本文介紹了PHP - 檢查頁面是否在移動或桌面瀏覽器上運行的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
在我的 PHP 頁面中,根據頁面是在移動瀏覽器還是桌面瀏覽器下運行,我應該顯示兩種不同的文本內容.有沒有辦法在 PHP 中執行這種控制?
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?
推薦答案
這里有一個非常好的 PHP 庫用于檢測移動客戶端:http://mobiledetect.net
There is a very nice PHP library for detecting mobile clients here: http://mobiledetect.net
使用它很容易只顯示移動設備的內容:
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
}
這篇關于PHP - 檢查頁面是否在移動或桌面瀏覽器上運行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!