2011-11-25 84 views
0

我不太瞭解PHP ...很不好,我知道。如果mobile_device_detect爲真,則爲條件語句

我爲移動/桌面網站使用http://detectmobilebrowsers.mobi/,我使用WordPress作爲我的CMS。

我已經建立了我的功能是這樣的...

require_once('mobile_device_detect.php'); 
    mobile_device_detect(true,true,true,true,true,true,false,false,false); 

但現在在我的主題,我想類似這樣的條件語句...

<?php if (is_home()) { ?> 

     //Some bits here 
    <?php } else { ?> 
     //Some bits here 
    <?php } ?> 

雖然我希望它從我的函數返回值。請參閱下面我下面的垃圾嘗試...

<?php if (mobile_device_detect==true) { ?> 

     //Some bits here 
    <?php } else { ?> 
     //Some bits here 
    <?php } ?> 

很顯然,這是行不通的笑,但你可以看到我想要達到什麼目的?和幫助將是最令人敬畏的謝謝!

乾杯 喬希

+1

我沒有答案,但我通過「立即購買」按鈕上'detectmobilebrowsers'網站可笑的數量很驚訝! – Roman

+0

哈哈精神不是它 – Joshc

回答

1

快到了。

require_once('php/mobile_device_detect.php'); 
$mobile = mobile_device_detect(true,true,true,true,true,true,false,false,false); 

然後檢查

if ($mobile==true) // then do the rest of your stuff 
+0

你的紳士,非常感謝老兄! – Joshc