-1

I am currently building a response class with PHP to communicate with my backend API if everything went alright. This is the class:

public static function Success($data = null)
{

    if (!$data) {
        return [
            'result'  => true
        ];
    } else {
        return [
            'result' => true,
            'data' => $data
        ];
    }
}

But when someone tries to install the plugin on a website it gives the error:

Parse error: syntax error, unexpected '[' in filename on line 13,

Line 13 is where the first bracket [ starts at the first return.

Does anyone know why I get this error? I think it has something to do with the version of PHP or Wordpress.

u_mulder
  • 54,101
  • 5
  • 48
  • 64
Gertjan Brouwer
  • 996
  • 1
  • 12
  • 35

1 Answers1

0

use

return array(
            'result'  => true
        );
DarkBee
  • 16,592
  • 6
  • 46
  • 58