1

I am having a syntax error on my craftCMS website. Hoping someone could help me.

Parse error: syntax error, unexpected '[' in /home16/puresoci/public_html/dev/craft/plugins/charge/ChargePlugin.php on line 14

Here's the line that it is referring to

  craft()->templates->hook('charge.prepCpTemplate', [$this, 'prepCpTemplate']);

Here's the whole function

public function init()
{
    craft()->charge_license->ping();

    if (craft()->request->isCpRequest()) {
        $this->includeCpResources();
        craft()->templates->hook('charge.prepCpTemplate', [$this, 'prepCpTemplate']);
        craft()->templates->hook('charge.prepCpSettingsTemplate', [$this, 'prepCpSettingsTemplate']);
    }
}

But I am a beginner on using PHP and I dont know how should I update this. I am using PHP 5.6 right now.

1

The Charge plugin requires a minimum of PHP 5.4.

The brackets notation for arrays (which is what Charge uses) was added in 5.4.

http://php.net/manual/en/language.types.array.php

Contact your hosting provider to find out how to upgrade.

4
  • I am using PHP 5.6 it works fine yesterday but when I open it today I got that error. – ChooeyCraft Dec 11 '17 at 23:54
  • Your post explicitly says you found a message stating "You are using PHP 5.3." I'd recommend you check again. – Lindsey D Dec 11 '17 at 23:56
  • Sorry about that the quote below 'You are using PHP 5.3. The Array Initialization Construct: [] will not work. Instead, use this approach:' is what I just researched in the internet. I am using PHP 5.6 right now. – ChooeyCraft Dec 11 '17 at 23:58
  • What I'm saying is, I don't think you are. Go to the /admin/utils/phpinfo page of your site, and see what it says there. That will tell you which version Craft itself is seeing. – Lindsey D Dec 12 '17 at 0:00
1

Honestly, if you can, I'd upgrade your hosting to use PHP 7. It's about 2x as fast as 5.x, and it's much more modern. PHP 5.3 isn't even supported anymore.

2
  • Sorry about that the quote below 'You are using PHP 5.3. The Array Initialization Construct: [] will not work. Instead, use this approach:' is what I just researched in the internet. I am using PHP 5.6 – ChooeyCraft Dec 11 '17 at 23:57
  • I updated my question so everyone will not get confused. – ChooeyCraft Dec 12 '17 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.