0

我使用 codeigniter-restserver 但我得到了类似的错误

解析错误:语法错误,意外的“类”(T_CLASS),在第 835 行的 xxxxxxxxxxxxx\application\libraries\REST_Controller.php 中需要标识符(T_STRING)或变量(T_VARIABLE)或“{”或“$”

这里的线

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;
            }
4

1 回答 1

1

将您的 PHP 更新到最新版本。

于 2019-01-27T10:48:31.820 回答