For example, if I provide a registration interface to ios developers, for example, if the registration is successful, then I want to return a status code to him. Should the original method be used to return the data?
`public function login(){
<code>$name=$_POST['name']; $password=$_POST['password']; if(){ return "成功"; }else{ return "失败"; }</code>
}`
For example, if I provide a registration interface to ios developers, for example, if the registration is successful, then I want to return a status code to him. Should the original method be used to return the data?
`public function login(){
<code>$name=$_POST['name']; $password=$_POST['password']; if(){ return "成功"; }else{ return "失败"; }</code>
}`
Return to json format
echo json_encode("success")
$data['code']='1';
$data['msg']="Login successful!";
exit(json_encode($data));
<code>json_encode(['status' => 1, 'message' => '成功']);</code>
Client does json parsing