I usually write about it.
echo $data
But I see people's code, a lot of them are
exit($data)
Reply content:
I usually write about it.echo $data
But I see people's code, a lot of them areexit($data)
In general, you should use the Echo
The function of exit () is to force the termination of the script and use it to output the result with the benefit of avoiding subsequent code execution
For example, this situation:
When the $arg is 0 o'clock, only output ' failed ' does not output "It s Wonderful"
But using exit () has one place to note:
If a number is passed to it, the number will be treated as an exit status code and will not be exported to the client
Can see the official description: Http://cn2.php.net/exit
Because this interface API in general is finished after the output, in order to prevent some logical problems caused by the subsequent code to continue, simply use here to exit()
output the results after the stop script. These are die
some of the party's personal sentiment.
Anyway, I like exit.
1. Reduce the pressure of business logic judgment
2. Exit PHP script execution immediately after completion
exit() die()
Personal experience is mainly after the output of the other output, affecting the client's normal receive parsing. Specific experiments can try, after the output after the output, the client received the data is wrong, small in the past to receive other people's projects have encountered, other friends said the same truth.