0

How can i correct the following php snippet to run it in php 5.3.3 without parsing error?

Browser Message

Parse error: syntax error, unexpected '['

PHP Code Snippet

{ public function getDelete($key = NULL) $_DELETE = [];
        parse_str(file_get_contents("php://input"), $_DELETE);
        return NULL !== $key ? self::arrayKey($key, $_DELETE) : $_DELETE;
        } 

error log message:

mod_fcgid: stderr: PHP Parse error: syntax error, unexpected '['

Brad
  • 159,648
  • 54
  • 349
  • 530
Cash
  • 17
  • 1
  • 3

1 Answers1

3

PHP 5.3 doesn't support the [] array syntax. Only PHP 5.4 and later does.

For older PHP, you need to use array() instead of [].

Brad
  • 159,648
  • 54
  • 349
  • 530
  • thanks. And in case of this line? $this->getAutoloader()->registerNamespaces([$namespace => $module]); – Cash Sep 03 '15 at 21:32
  • 1
    @Cash Same issue there. You really should ditch PHP 5.3 though. It's unsupported for a year now - major security issues likely exist in it. – ceejayoz Sep 03 '15 at 21:37
  • @Cash `$this->getAutoloader()->registerNamespaces(array($namespace => $module));` – Brad Sep 03 '15 at 21:55