首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

symfony:setHttpHeader()不起作用,header()没有

作用,要设置HttpHeader,直接在response中设置即可,例如:

代码语言:php
复制
$response = new Response();
$response->headers->set('Content-Type', 'text/html');
$response->send();

另外,如果你想在Symfony中设置HttpHeader,也可以使用以下方法:

代码语言:php
复制
$response = $this->render('your_template.html.twig', array(
    'http_headers' => array(
        'Content-Type' => 'text/html',
    ),
));

这样,在渲染模板时,会自动设置相应的HttpHeader。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

  • 领券