Comments (8)
it's MobileDetect.php
Not Mobile_Detect.php
from mobile-detect.
@ioempire you downloaded 4.x version which contains the file /src/MobileDetect.php
thank you @microchip8
from mobile-detect.
Thanks
Now I get this error:
[16-Jan-2024 09:49:03 UTC] PHP Fatal error: Uncaught Error: Class "Detection\Cache\Cache" not found in /home/friudeni/public_html/Mobile-Detect/src/MobileDetect.php:1032
Stack trace:
#0 /home/friudeni/public_html/index.php(30): Detection\MobileDetect->__construct()
#1 {main}
thrown in /home/friudeni/public_html/Mobile-Detect/src/MobileDetect.php on line 1032
In line 30 I have:
$detect = new MobileDetect();
I Use php version 8.0
from mobile-detect.
@ioempire it's because you're not using composer autoload like in this example https://github.com/serbanghita/Mobile-Detect/blob/4.8.x/scripts/example.php
you will have to manually include
all dependent files from https://github.com/serbanghita/Mobile-Detect/tree/4.8.x/src
from mobile-detect.
But what is this line:
require_once DIR . '/../vendor/autoload.php';
vendor and autoload.php is not in the Mobile-Detect directory
from mobile-detect.
Now my code look like this:
$mobil=0;
include($_SERVER['DOCUMENT_ROOT']."/Mobile-Detect/src/Cache/CacheException.php");
include($_SERVER['DOCUMENT_ROOT']."/Mobile-Detect/src/Cache/Cache.php");
include($_SERVER['DOCUMENT_ROOT']."/Mobile-Detect/src/Cache/CacheItem.php");
include($_SERVER['DOCUMENT_ROOT']."/Mobile-Detect/src/Exception/MobileDetectException.php");
require($_SERVER['DOCUMENT_ROOT']."/Mobile-Detect/src/MobileDetect.php");
use Detection\MobileDetect;
$detect = new MobileDetect();
$detect->setUserAgent();
if( $detect->isMobile() && !$detect->isTablet() )
$mobil =1;
And I get this error:
[16-Jan-2024 10:56:06 UTC] PHP Fatal error: Uncaught Error: Interface "Psr\SimpleCache\CacheInterface" not found in /home/friudeni/public_html/Mobile-Detect/src/Cache/Cache.php:7
Stack trace:
#0 /home/friudeni/public_html/index.php(30): include()
#1 {main}
thrown in /home/friudeni/public_html/Mobile-Detect/src/Cache/Cache.php on line 7
from mobile-detect.
@ioempire 4.8 is meant to be used with composer with composer require mobiledetect/mobiledetectlib
, in the above case you're missing a dependency.
I'm sorry for misguiding you, I didn't realised that 4.8 is fully dependent on composer autoload (which is kinda like what modern PHP env looks like).
Just start from scratch use the code from 2.8
branch
https://github.com/serbanghita/Mobile-Detect/tree/2.8.x then you don't need to include anything, see https://github.com/serbanghita/Mobile-Detect/blob/2.8.x/examples/test.php - it's the same detection, but the code is compatible with classic way of manually including the class.
from mobile-detect.
In summary:
4.8 - use composer and example https://github.com/serbanghita/Mobile-Detect/blob/4.8.x/scripts/example.php
2.8.x - you can use classic include - https://github.com/serbanghita/Mobile-Detect/blob/2.8.x/examples/test.php
from mobile-detect.
Related Issues (20)
- Safari on iPad: completely incorrect reports HOT 1
- Trying to get in touch regarding a security issue HOT 2
- MD v 3.74 - PHP Parse error: syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST) in Mobile_Detect.php on line 245 HOT 1
- How to check Desktop site setting On OR Off in mobile browser
- isMobile doesn't cache matches HOT 2
- isEdge() return false on Edge Browser
- 4.8.x HOT 4
- isMobile and IsTablet failing on ios devices - using safari HOT 1
- Port functionality from `jenssegers/agent` HOT 11
- Restore implicit use of `HTTP_USER_AGENT` in 4.8.x branch HOT 3
- Chrome's user agent reduction results in no longer detecting Android tablets as a tablet device HOT 1
- Getting a Parse error on the latest version (4.8.03) on PHP 7.1.33 HOT 4
- Google SERP links open as the mobile version HOT 5
- [bug] No user-agent has been set HOT 18
- [bug] breaking change pushed as patch HOT 3
- Need advice on `No valid user-agent has been set` PHP Fatal error HOT 4
- Tablet IOS detection HOT 1
- php 8.4 - implicit nulls are deprecated HOT 1
- Windows Wechat
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mobile-detect.