2011-11-25 63 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