Im在Wordpress安裝中使用Serbanghita's PHP Mobile Detect類。我已經在我的header.php文件中以下內容:PHP Mobile Detect Wordpress
<?php
include 'php/Mobile_Detect.php';
$detect = new Mobile_Detect();
?>
當我把我的single.php文件裏面下面我接到一個電話在非對象錯誤:
<?php if ($detect->isMobile()) {
//Do something
} ?>
任何想法?我無法將include包括到我的single.php文件中,因爲我需要在header.php中使用它,當然我不能將它複製到single.php文件中,因爲那樣我就會聲明類。
任何幫助,非常感謝。
而不是你可以使用這個wordpress內置函數wp是mobile http://codex.wordpress.org/Function_Reference/wp_is_mobile – 2013-03-07 07:28:02