Rewrite PHP Statement For Version 5.3.28

Hi all,

I’m having a little trouble getting an extension working with my Opencart 2 store.

I’m getting the following parse error:

Parse error: syntax error, unexpected ‘[’ in /home/mysite/public_html/system/modification/catalog/controller/common/footer.php on line 46

The line in question is:

[php]$data[‘about_desc’] = html_entity_decode($this->config->get(‘config_about_description’)[$this->config->get(‘config_language_id’)], ENT_QUOTES, ‘UTF-8’);[/php]

After a little digging I discovered that this code is not compatible with the version of PHP on my hosting account, which is version 5.3.28.

Could someone please rewrite this statement to work with PHP 5.3.28

Many thanks!

Your problem is accessing the returned array from the get method directly

[php]html_entity_decode($this->config->get(‘config_about_description’)[$this->config->get(‘config_language_id’)][/php]

This is valid php, but it wasn’t added until 5.4
[php]$object->method()[‘key’][/php]

[hr]

You just need to do it in two operations. So instead of
[php]html_entity_decode($this->config->get(‘config_about_description’)[$this->config->get(‘config_language_id’)][/php]

You do
[php]$configAboutDescription = $this->config->get(‘config_about_description’);
html_entity_decode($configAboutDescription[$this->config->get(‘config_language_id’)][/php]

http://php.net/manual/en/language.types.array.php#example-101

Hi Jim, thanks for the reply.

Do I then pass $configAboutDescription into $data[‘about_desc’] ?

no the result of html_entity_decode

Ah right, got it :slight_smile:

Many thanks!

Sponsor our Newsletter | Privacy Policy | Terms of Service