My API End point has return statement instead of print or echo : e.g.
return json_encode($data);
instead of
print json_encode($data);
I have a curl caller to consume my API. When I try to display the result, it shows null. However if I change API End point to :
print json_encode($data);
I can see the result.
Any idea how can I deal with return statement.
print
(orecho
) does what you want, why do you want to usereturn
?print
orecho
. The whole point of return is to not do that. return is for passing data between functions/variables.