如何在cakephp中写内容类型? [英] How to write content type in cakephp?

查看:155
本文介绍了如何在cakephp中写内容类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在cakephp中写入[Content-Type] =text / xml,我必须在其中包含该文件。

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

谢谢。

推荐答案

Cake方法是使用< a href =http://book.cakephp.org/view/1295/Responding-To-Requests =nofollow> RequestHandlerComponent :: respondAs ,例如

$ this-> RequestHandler-> respondAs('xml'),在控制器中的某处。如果您的应用设置正确,则这可能会自动发生。

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.

PHP方法是在任何输出之前的任何地方发出 header('Content-Type:text / xml') )。

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

这篇关于如何在cakephp中写内容类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆