when call function of class (in included file), text being output echo
. need store in variable.
here code:
require_once('../restapis/api.php'); class apitest { public function testapis(){ $api = new api(); $api->validate_request(); } } $obj = new apitest(); $obj->testapis();
and getting json string echoed in browser:
{"errorcode":"e032","errormessage":"invalid url."}
i don't have permission change in api.php
file, that's why can't change echo
return
.
is there way can this?
you use output buffering.
ob_start(); // activate output buffering $obj->testapis(); // whatever code output want capture $contents = ob_get_contents(); // store buffered contents ob_end_clean(); // deactivate output buffering
after that, $contents
contain echoed output.
Comments
Post a Comment