Php Codeigniter服务器REST
通过遵循本教程,我在codeigniter rest v 2.1.1上创建了一个服务器。 我在文件REST\u Controller.php中有一个错误Php Codeigniter服务器REST,php,codeigniter,rest,Php,Codeigniter,Rest,通过遵循本教程,我在codeigniter rest v 2.1.1上创建了一个服务器。 我在文件REST\u Controller.php中有一个错误 // How is this request being made? POST, DELETE, GET, PUT? $this->request->method = $this->_detect_method(); 我的代码: <?php require(APPPATH . 'libraries/
// How is this request being made? POST, DELETE, GET, PUT?
$this->request->method = $this->_detect_method();
我的代码:
<?php
require(APPPATH . 'libraries/REST_Controller.php');
class Api extends REST_Controller {
function test_get() {
$this->response(array('success' => 'Yes it is working'), 200);
}
}
如何修复错误?在Rest\u controller.php中尝试此代码
添加这些行
if(!is_object($this->request))
{
$this->request= new stdClass();
}
年初
publict function __construct()
{
parent::__construct();
$this->load->config('rest');
//some where here like
if(!is_object($this->request))
{
$this->request= new stdClass();
}
$this->request->method = $this->_detect_method();
......
....
...
}
这并没有解决我的问题。
publict function __construct()
{
parent::__construct();
$this->load->config('rest');
//some where here like
if(!is_object($this->request))
{
$this->request= new stdClass();
}
$this->request->method = $this->_detect_method();
......
....
...
}