2013-10-01 21 views
0

我已經下載了一個php代碼來檢測設備(手機或平板電腦)。它是工作的核心,但。但檢測後,當我試圖重定向到另一個頁面它不工作Php代碼來檢測mobilie或tab

Here is the detect method i have call

和代碼如下

$detec=detectBrowser(); 
if($detec==true) 
{ 

header("location: http://www.google.com"); 
} 

在打印打招呼而不是重定向。

+0

看看你用'@'壓制的錯誤。如果你刪除'@',你會看到爲什麼它不起作用。 – Lix

+0

@rid - 如果錯誤信息被抑制,顯然不是那麼明顯:) – Lix

+0

我也檢查過它沒有@ –

回答

0

二線你的PHP文件(後<?php):

// Turn on ALL error reporting 
ini_set('display_errors',1); 
error_reporting(E_ALL); 

檢測代碼:

$detect = detectBrowser(); 
if($detect == true) { 
    // The user is using a mobile device. Proceed to the next URL. 
    header("Location: http://www.url.com/mobile/"); 
} else { 
    // The user is not using a mobile device. 
    header("Location: http://www.url.com/non-mobile/"); 
} 

試試這個代碼。它會檢查用戶是否不在移動設備上,是否重定向到非移動設備,或者用戶是否正在使用移動設備,然後移動到移動站點。