考虑我的控制器名称是Api_example,并且我扩展了REST_Controller。 现在我的困惑是codeigniter中restful api的方法名称是什么?
public function user_get(){
//Some code..
}
public function user_post(){
//Some code..
}
现在,我无法理解什么是“用户”在那种方法。如果我访问user_get()
方法,如localhost/api_example/user/get
或localhost/api_example/user/post
只是显示一些array
data
json
格式。它不工作。 请帮帮我。
感谢您的回答。但我想知道'user_get()'中的'user'这个前缀词是什么。我看过很多例子,但有人使用'index_get()/ index_post()'。 –
我编辑我的答案,我希望我帮你 –
我明白,直到你expalined,现在,如果我遵循该过程,我得到一个'未知方法'exceptionfor user_post()。我需要改变route.PHP中的任何内容吗?现在我已经提到['api_example/user /(:any)'] = ['api_example/user_post']。但我不确定。 –