-1

I am trying to get a WordPress site working on a server running PHP 5.3. I am not able to update the server so am trying to make things compatible.

I am getting the following error...

Parse error: syntax error, unexpected '['

The line that is causing the error is...

echo wp_get_attachment_image($mysection['imageid'], 'medium', "", ["class" => "side_img"] );

Any ideas how to modify this code to be compatible?

fightstarr20
  • 11,682
  • 40
  • 154
  • 278

2 Answers2

3

The short array syntax was first introduced in PHP 5.4. PHP 5.3 does not understand what ["class" => "side_image"] is, hence the syntax error.

The solution is simple, change:

["class" => "side_image"]

into:

array("class" => "side_image")

cabrerahector
  • 3,653
  • 4
  • 16
  • 27
1

PHP 5.3 does not support the "short array syntax" like [1, 2, 3, 4]. These must be converted to array(1,2,3,4).

See here: http://php.net/manual/en/migration54.new-features.php

bernie
  • 9,820
  • 5
  • 62
  • 92