Home >Backend Development >PHP Tutorial >Swift - PHP develops ios interface. Please give me some advice.

Swift - PHP develops ios interface. Please give me some advice.

WBOY
WBOYOriginal
2016-09-14 09:41:29933browse

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>

}`

Reply content:

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn