我是一個站長和我目前努力增加幾頁簡單的版本,以創建一個子網站爲移動瀏覽器。因此,我想從整個網站的移動網站重定向用戶使用移動設備瀏覽和我寧願用PHP來做到這一點。我找到的那個人有很好的評論,但我無法讓它工作。我每次查看發佈索引頁(這是一個PHP文件),我得到:PHP移動設備重定向援助
Fatal error: Class 'Mobile_Detect' not found in D:\Hosting\4872190\html\php\index.php on line 4
在目錄中,我有以下的文件和文件夾:index.php文件, 移動(文件夾),mobilehome。 php(手機),events.php(手機),news.php(手機)。
顯然,用戶進入網站,這將加載的index.php的主要URL,並且該文件將在移動瀏覽器中發現重定向到移動/ mobilehome.php。
下面是兩個文件供參考的內容:index.php文件和mobile_detect.php(我下載的PHP類的一部分)。
的index.php
<?
include 'mobile_detect.php';
$detect = new Mobile_Detect;
if(!$_SESSION['isMobile']){
$_SESSION['isMobile'] = $detect->isMobile();
}
if($detect->isMobile()){
header('mobilehome.php', true, 301);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />...
您可以查看代碼的mobile_direct.php類我通過點擊下面的網址下載。
http://www.troop322dc.com/php/mobile_redirect.html
什麼原因造成的問題?任何援助將不勝感激。非常感謝你提前。
嘗試'新Mobile_Detect();'(用方括號)。 – Mansfield
鏈接不起作用。 –