【发布时间】:2019-06-26 14:09:20
【问题描述】:
我正在使用以下代码测试数据的发布,但发布数据始终为空我尝试使用邮递员进行测试但它不起作用,以下是我编写的测试代码但它总是进入 else 块,我尝试编写else if 也一样,但它不起作用
class Api_home extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->model('Api_model','api');
$this->load->helper('form');
$data= array(
'message' => ' Something went wrong',
'status' =>1,
'data' =>'',
);
}
public function test(){
$lang= $this->input->post['lang'];
if($lang=="ar"){
$this->data['message']= 'Arabic test';
}
//else if
// else if($lang=="en")
else{
$this->data['message']= 'English test';
}
$data['status']= 1 ;
echo json_encode($data,true);
die;
}
即使我发布了 ar,它也总是转到 en 版本,如果我为发布的数据执行 var_dump,它会给我 false。请告诉我如何排序它
我总是得到以下回应
【问题讨论】:
-
$lang= $this->input->post['lang'];错误,正确的是$lang= $this->input->post('lang');
标签: php json codeigniter postman