-1

I am working on a google analytics dashboard which will display marketing campaign results for the customers. I am using google analytics api but I keep getting this error ( Parse error: syntax error, unexpected '=' in /home2/.../.../vendor/laravel/framework/src/Illuminate/Support/Arr.php on line 388). I searched about the error and found that it is because of a mismatch of the php version between apache server and CLI.my CLI php version used to be 7.1.12 and my apache version was 7.1.14. I upgraded it to 7.1.14 but I am still facing the same error.

Noof
  • 1
  • 2

1 Answers1

0

This is the offending line from Arr.php:

[$value, $key] = static::explodePluckParameters($value, $key);

It seems your PHP server is still running version < 7.1.0 and it doesnt support this array notation

To test it, you can use following code (php 5.x and php < 7.1.0 throws parse error):

[$value, $key] = explode("|",'some|thing');
var_dump($value,$key);
Michail Strokin
  • 531
  • 3
  • 8
  • I'm sorry, PHP 7.10? What? If you are from the future, please send me lottery numbers. – user1597430 Dec 09 '18 at 07:01
  • ..Sorry again, haven't slept properly today, I meant this array notation was introduced in 7.1.0 I think :)) – Michail Strokin Dec 09 '18 at 07:02
  • You know, OP is not able to test any [$a, $b] with var_dump because he has a "Parse Fatal Error" on the same code right now. I mean, what's new do you want to show him? – user1597430 Dec 09 '18 at 07:08
  • Yeah, agreed, var_dump isn't needed here :) – Michail Strokin Dec 09 '18 at 07:12
  • what should I add inside the two quotation marks?.. I am novice so please bear with me. – Noof Dec 09 '18 at 07:52
  • Old syntax: `list($a, $b) = $array`, new syntax: `[$a, $b] = $array`, you may use `list` instead of brackets if you don't want to update the PHP version and if you are sure that the code don't use inside a lot of new features like this. – user1597430 Dec 09 '18 at 07:53
  • Changing vendor code is a bad practice. Either upgrade the PHP version or downgrade Laravel (but I strongly advise against it) – Michail Strokin Dec 09 '18 at 11:50
  • I just uplaod a php file contain to the host, and found out the php version is 7.0.31. php artisan --version output is (laravel framework 5.7.13). and also php -v output is 7.1.14. I am not sure how to upgrade my server and if it is better to downgrade laravel instead of missing up with the server? – Noof Dec 10 '18 at 06:24
  • PHP 7.0.x will stop receiving security patches in 3 weeks (it's End-Of-Life is set to 1st of Jan 2019), so I not upgrading is a really bad idea :) – Michail Strokin Dec 10 '18 at 13:44