Closed Lavrynenko closed 1 year ago
As stated here: https://github.com/serbanghita/Mobile-Detect/releases/tag/3.74.0
library exported as Detection\MobileDetect
I think that's your issue. Just add:
use Detection\MobileDetect;
At the beginning of your script.
use Detection\MobileDetect;
I try the code: <?php use Detection\MobileDetect; require_once 'MobileDetect.php'; $detect = new Mobile_Detect; echo "$detect"; ?>
And I get an error :( I'm doing something wrong, but what? :(
What you're doing wrong is that you don't provide the test.php
source code :-)
Что вы делаете неправильно, так это то, что вы не предоставляете
test.php
исходный код :-)
Grabbed my head :(
The code: use Detection\MobileDetect; require_once 'MobileDetect.php'; $detect = new Mobile_Detect; echo "$detect";
You must have another issue (that's not the first one you've opened this issue for).
OK, I've spotted it, you still use Mobile_Detect
instead of MobileDetect
.
Try:
<?php
use Detection\MobileDetect;
require_once 'MobileDetect.php';
$detect = new MobileDetect();
var_dump($detect->isMobile());
You must have another issue (that's not the first one you've opened this issue for).
OK, I've spotted it, you still use
Mobile_Detect
instead ofMobileDetect
.Try:
<?php use Detection\MobileDetect; require_once 'MobileDetect.php'; $detect = new MobileDetect(); var_dump($detect->isMobile());
Thank you!! Everything worked - tested on a mobile device and a computer. If from a mobile device - true, otherwise - false :)
Thank you very much for your help!
There is the file test.php: <?php require_once 'MobileDetect.php'; $detect = new MobileDetect; echo "$detect"; ?>
File "MobileDetect.php" located in the same folder. But when I run the code, I get an error: Fatal error: Uncaught Error: Class 'MobileDetect' not found in C:\xampp\htdocs\Php\telegramid.net\test.php:3 Stack trace: #0 {main} thrown in C:\xampp\htdocs\Php\telegramid.net\test.php on line 3
File "MobileDetect.php" downloaded from https://github.com/serbanghita/Mobile-Detect/archive/refs/tags/3.74.0.zip
PHP version: 7.4.33
please tell me what is wrong? Thank you!