使用echo&exit结束php中的一个函数

When I post data to a function in php page, it continues to run over all lines. I mean while debugging I retrieve my data with echo json_encode(..) And continue in next line to debug. So I use exit to stop it. But it means I have to use exit each echo..

 echo json_encode($resultData);
                exit; //if I don't use this, interprets goes on

In real scenario, I though it will improve performance because I don't need php interpreter check the other lines.. or I have misunderstood completely on this?

To direct the result to the calling function use return json_encode($resultData);

If just want to output your results use

echo json_encode($resultData);
return false;

To make it with one function you can use exit() or die() instead of echo + exit, for example:

exit(json_encode($resultData));

or

die(json_encode($resultData));

They are equivalent to each other, but die is one character shorter.