ecruzartist
Member
I was using the Mobile_Detect class (http://mobiledetect.net/) back in 1.5. Upon the switch to XF2, I'm getting an error.
PHP Fatal error: Cannot redeclare class Mobile_Detect in /path/to/file/Mobile_Detect.php on line 24
The error happens unless $detect = new Mobile_Detect; is commented out, which causes $isMobile to be null.
Clearly, I'm including this class incorrectly. What's the right way to do this?
PHP Fatal error: Cannot redeclare class Mobile_Detect in /path/to/file/Mobile_Detect.php on line 24
Code:
namespace loadMyStuff;
class loadThisThing {
public static function getHtml(){
ob_start();
require_once '/path/to/file/Mobile_Detect.php';
$detect = new Mobile_Detect;
if ($isMobile){ echo "mobile"; }else{ echo "desktop"; }
$collectOutput = ob_get_contents();
ob_end_clean();
return $collectOutput;
}
}
Clearly, I'm including this class incorrectly. What's the right way to do this?
Last edited: