I am running a typical php-engined ajax webpage. I use echo to return a html string from the php code. My question is, if I have some other code after the echo, will those code get executed? Or echo behaves similar to exit, which immediately return and stop running the php code? Thanks.
Echo sends output to the output buffer, If it's embedded in HTML (which is also being sent to the output buffer) then it appears that it writes that to the "source".
No, not directly, as JavaScript ist executed on the client side, and PHP is executed on the server. A workaround would be to send another AJAX-Request from your success-function.
The exit() function in PHP is an inbuilt function which is used to output a message and terminate the current script. The exit() function only terminates the execution of the script.
The exit() function prints a message and terminates the current script.
No, echo
in no way exits, you normally have more than one echo in a script. exit
does take a string argument that it will output before exiting, however, so you can do:
exit("your string here");
and it will output the string and exit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With