PHP Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW)
microlancer opened this issue · comments
Tim commented
I am getting this error:
[Tue Dec 05 06:35:13.815808 2023] [php7:error] [pid 20734] [client 185.38.129.92:30944] PHP Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ')' in /home/user/work/ifm/ifm.php on line 5041
$ php -v
PHP 7.3.27-1~deb10u1 (cli) (built: Feb 13 2021 16:31:40) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.27-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies
The line of code in question seems to be:
$IPS = array_merge($ips, array_map(fn($i) => $i['ip'] ?? $i['ipv6'], dns_get_record($parts['host'], DNS_A + DNS_AAAA)));
And according to some search, I found that the arrow function => was introduced in PHP 7.4
The documentation for installation says this only requires PHP 5.6 or newer.
I'll try to upgrade my system if I can, but it might be good to either update the install docs or change this arrow function.
Marco Dickert commented
You are right. I replaced the arrow function.