如何通过php返回响应

I'm writing a php api with methods wired together by php routing, such that

dev.myphp.com/user/login?email=sdfsdf@fdfd.com&password=d514

will return a json/xml response.

However, I do not know how to return this response, even if I use json_encode or xml_encode to conver the data string.

Do I just need to uniquely echo the JSON string out?

Always try to take data using POST method not GET , untill unless you don't find it less useful in caompare to POSt.

use simply

<?Php
--- php code 

return json_encode($resultdata);

?>

it would be enough.