Im trying to create a class that I can request to return a variable based on some mobile detection. Im trying to avoid defining anything with global
. I'm getting the following error: Parse error: syntax error, unexpected 'new' (T_NEW)
<?php
require_once 'lib/Mobile_Detect.php';
class detectDevice {
private static $detect = new Mobile_Detect;
private static $deviceType;
public static function returnDevice(){
if ( $detect->isMobile() ) {
$deviceType = "IS MOBILE";
}
if( $detect->isTablet() ){
$deviceType = "IS TABLET";
}
print self::$deviceType;
}
}
echo detectDevice::returnDevice();
?>
Any suggestions?