serbanghita / Mobile-Detect

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
http://mobiledetect.net
MIT License
10.54k stars 2.68k forks source link

Getting a Parse error on the latest version (4.8.03) on PHP 7.1.33 #943

Closed colindesaulniers closed 1 year ago

colindesaulniers commented 1 year ago

Why am I getting this error message when I try to upgrade the script from version 2.8.41 to the latest 4.8.03. Running on CentOS 7 with PHP 7.1.33

Got error 'PHP message: PHP Parse error: syntax error, unexpected 'Cache' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /var/www/vhosts/xxxxxxxxxx/httpdocs/php_includes/MobileDetect.php on line 234

Line 234 shows: protected Cache $cache;

I've been trying to upgrade to the latest a few times but keep running into this issues. I haven't modified any of the code.

Am I doing something wrong? Do I need to change something? Is there a fix that needs to be implemented?

The script has been great for so many years but I just haven't been able to swap out the the latest version for the last year.

Any help would be greatly appreciated. Thanks.

serbanghita commented 1 year ago

@colindesaulniers 4.8.x is for PHP >= 8.0

image

serbanghita commented 1 year ago

@colindesaulniers can you by any chance upgrade to PHP 7.3 and use 3.74.x?

colindesaulniers commented 1 year ago

That's my oversight. Thanks for pointing that out.

serbanghita commented 1 year ago

@colindesaulniers no worries, I've updated the matrix support badges last night to be more explicit. I will also add tests badges for all specific versions so it will be clear which version works on 7.1

Screenshot 2023-10-17 at 10 25 55