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.

Home Page:http://mobiledetect.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

colindesaulniers opened this issue · comments

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.

@colindesaulniers 4.8.x is for PHP >= 8.0

image

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

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

@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