0

I use codeigniter-restserver but i got error like

Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in xxxxxxxxxxxxx\application\libraries\REST_Controller.php on line 835

here the line

if (method_exists(Format::class, 'to_' . $this->response->format))
            {
                // Set the format header
                $this->output->set_content_type($this->_supported_formats[$this->response->format], strtolower($this->config->item('charset')));
                $output = Format::factory($data)->{'to_' . $this->response->format}();

                // An array must be parsed as a string, so as not to cause an array to string error
                // Json is the most appropriate form for such a data type
                if ($this->response->format === 'array')
                {
                    $output = Format::factory($output)->{'to_json'}();
                }
            }
            else
            {
                // If an array or object, then parse as a json, so as to be a 'string'
                if (is_array($data) || is_object($data))
                {
                    $data = Format::factory($data)->{'to_json'}();
                }

                // Format is not supported, so output the raw data as a string
                $output = $data;
            }
Shikai
  • 11
  • 1
    Seems like you could be running a dated version of the PHP interpreter. Use of ::class was added in PHP 5.5 https://secure.php.net/manual/en/language.oop5.basic.php#language.oop5.basic.class.class – Oluwafemi Sule Jan 27 '19 at 04:28

1 Answers1

1

Update your PHP to the leatest version.

Majid Ramzani
  • 358
  • 5
  • 12