php ajax页面输出

in my case , i need to return value from a ajax page. as i know , there is two way to do it: echo , return.

echo 0;
exit;

or

return 0;
exit;

is there any different between them?

AJAX retrieves the output from another page. echo will output something, but return is for returning a value from a function.

Use echo.

If I were you, I would use :

echo '0'; 
exit();

Why ? Because you don't want to output an integer (treated as bool in PHP, I assume 0/1). You want a string so AJAX can read it.

Return is for function and stuff, not to end a page.