0

I am writing a code for GCM push notification. The code is working fine in local environment (Ubuntu 14.04 with xampp and Windows 8 with xampp) I am getting the push notifications too.

But when I deploy it in live server (Centos with lampp) I get syntax error

The code snippet which tiggers the syntax error is given below

 private function getHeaders()
{
    return [
        'Authorization: key=' . $this->apiKey,
        'Content-Type: application/json'
    ];
}

The live server error log is given below

[Fri Jan 22 08:28:49 2016] [error] [client 103.193.88.66] PHP Parse error:  syntax error, unexpected '[' in /var/www/html/api.contribilling.com/include/Pusher.php on line 69

Line 69 => return [

Any idea why this error? Is it because of some misconfiguration on the live server end?

Rick Roy
  • 1,656
  • 2
  • 21
  • 47

1 Answers1

0

PHP 5.4 + supports [] for arrays. These brackets will cause an error in earlier versions of PHP. You either need to use () brackets for arrays, or upgrade your PHP version on the production server.

devlin carnate
  • 8,309
  • 7
  • 48
  • 82