0

My script is working really fine on my xampp php version 5.6. Now I tried to upload it on the server php version 5.3.3 , it says

PHP Parse error:  syntax error, unexpected '['

The line which its mocking about is this one:

$this->pending_nodes[$number] = [];

The whole code block looks like this:

public function addPendingNode(ProtocolNode $node){
  $from = $node->getAttribute("from");
  if(strpos($from,Constants::WHATSAPP_SERVER) !== false)
    $number = ExtractNumber($node->getAttribute("from"));
  else
    $number = ExtractNumber($node->getAttribute("participant"));

  if(!isset($this->pending_nodes[$number]))
    $this->pending_nodes[$number] = [];

  $this->pending_nodes[$number][] = $node;
}

I am thankful for any help, I cannot seach [ with google and have no idea where it could come from, since on xampp its working fine.

5
  • for 5.3 try this $this->pending_nodes['.$number.'] = []; Commented Dec 22, 2015 at 8:26
  • @DanyalSandeelo what you suggested would cause a parse error. Commented Dec 22, 2015 at 8:49
  • @tontonlayxx I would suggest upgrading php to 5.6 - Given 5.3 and 5.4 are unsupported; 5.5 is deprecated: Supported Versions Commented Dec 22, 2015 at 8:52
  • I am also to upgrade my server php version @ash Commented Dec 22, 2015 at 8:53
  • thinking to upgrade* @ash Commented Dec 22, 2015 at 9:04

1 Answer 1

2

Short Array syntax was introduced in PHP 5.4 only.

Change

$this->pending_nodes[$number] = [];

to

$this->pending_nodes[$number] = array();

or upgrade to a PHP version that is not End of Life.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.