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.

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-09-14 09:41:29
Original
954 people have browsed it

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>
Copy after login
Copy after login

}`

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>
Copy after login
Copy after login

}`

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>
Copy after login

Client does json parsing

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template