💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# Http\\Response->header [TOC] 设置`HTTP`响应的`Header`信息。 ~~~ function Http\Response->header(string $key, string $value, bool $ucwords = true); ~~~ ## 参数 * `$key`,`Http`头的`Key` * `$value`,`Http`头的`Value` * `$ucwords`是否需要对`Key`进行`Http`约定格式化,默认`true`会自动格式化 ## 返回值 * 设置失败,返回`false` * 设置成功,没有任何返回值 ## 注意事项 * `header`设置必须在`end`方法之前 * `$key`必须完全符合`Http`的约定,每个单词首字母大写,不得包含中文,下划线或者其他特殊字符 * `$value`必须填写 * `$ucwords`设为`true`,swoole底层会自动对`$key`进行约定格式化 > `Swoole`底层不允许设置相同`$key`的`Http`头 ## 示例 ~~~ $response->header('Content-Type', 'image/jpeg', false); $response->header('content-type', 'image/jpeg', true); ~~~