Я новичок в REST
API. У меня есть приложение REST Api
с Codeigniter
но это дает ошибку. Пожалуйста, помогите мне удалить ошибку.
Контроллер: -
<?php
требуют (AppPath '/ библиотеки / REST_Controller.php'.);
Класс Example_api расширяет CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model('user_model');
}
function user_get($this->get('id'))
{
if(!$this->get('id'))
{
$this->response(NULL, 400);
}
$user = $this->user_model->get_user($this->get('id'));
if($user)
{
$this->response($user, 200); // 200 being the HTTP response code
}
else
{
$this->response(NULL, 404);
}
}
function users_get()
{
$users = $this->user_model->get_all();
if($users)
{
$this->response($users, 200);
}
else
{
$this->response(NULL, 404);
}
}
}
Модель: -
<?php
класс User_model расширяет CI_Model {
function __construct(){
parent::__construct();
}
public function get_user($id){
$q=$this->db->get_where("employee",$id);
return $q->result_array();
}
public function get_all(){
$q=$this->db->get("employee");
return $query->result_array();
}
}
?>
Ошибка при тестировании в Post Man Api: -
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>An uncaught Exception was encountered</h4>
<p>Type: ParseError</p>
<p>Message: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ')'</p>
<p>Filename: C:\xampp\htdocs\Api\application\controllers\Example_api.php</p>
<p>Line Number: 15</p>
<p>Backtrace:</p>
<p style="margin-left:10px">
File: C:\xampp\htdocs\Api\index.php
<br />
Line: 315
<br />
Function: require_once
</p>