php - CakePHP how to set Content type header in appController? -


i have shared function extended controllers print give json object response.

i placed shared function "appcontoller.php" static function.

problem cannot access this-> in appcontroller.

question is:

how can solve it?

here code of function:

public static function printjsonoutput($responsedata) {     $this->requesthandler->respondas('json');     $this->autorender = false;     echo json_encode($responsedata); } 

thanks help.

read book json , xml views.

what want explained there in great detail, code examples , shown right way it.

what wrong , @nunser pointed out don't have access $this in static function. might want oop tutorial php first?


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -