php - 如何在 symfony 中返回特定的状态码(例如 24)

标签 php http symfony1 http-headers

我需要在 symfony 中为 API 返回疯狂的 http 代码状态

我需要返回状态码 24 我尝试这样做:

$this->getResponse()->setStatusCode('24');

但我总是收到响应代码 500

当我尝试返回“正常”状态代码(如 404、403)时:

$this->getResponse()->setStatusCode('403');

没有问题

有什么想法吗?

最佳答案

024 是一个无效 HTTP 代码(这与“未定义”不同)。有效的 HTTP 代码在 100-599 范围内。

关于php - 如何在 symfony 中返回特定的状态码(例如 24),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4398828/

相关文章:

http - 谷歌应用程序脚本 : testing doPost() with cURL

php - Doctrine 中的额外 changeColumns generate-migrations-diff

mysql - 如何在 symfony 中添加自定义 mysql 数据库

javascript - 使用 Ajax 从 mysql 获取行

php - 未找到列 : 1054 Unknown column laravel

php - 使用户无法访问 'sitemap.xml',但机器人可以访问

rest - HTTP 授权和 WWW-Authenticate header

php - 在 mySQL 查询中使用 MAX() 会产生有问题的结果

java - 在 HtmlUnit 中设置代理

symfony1 - Symfony 1.4 中的路由 : Is there a way to allow sf_method = OPTIONS for preflight HTTP requests