Following regex can be used to determine if the user is using mobile or not.
echo preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
Global array $_SERVER["HTTP_USER_AGENT"] can also be printed to get user information.