Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write content type in cakephp?

How can i write ["Content-Type"] = "text/xml" in cakephp and in which file i have to include that one.

Please Help.

Thanks.

like image 642
rajesh Avatar asked Jul 02 '26 22:07

rajesh


1 Answers

The Cake way is to use RequestHandlerComponent::respondAs, like
$this->RequestHandler->respondAs('xml'), somewhere in the controller. This may even happen automatically if your app is set up appropriately.

The PHP way is to issue header('Content-Type: text/xml') anywhere before any output (usually somewhere in the controller).

like image 176
deceze Avatar answered Jul 05 '26 16:07

deceze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!