CodeIgniter-在请求标头中打印自定义值


CodeIgniter - print custom values in request header

如何使用CodeIgniter打印接收到的请求标头中设置的值?

我尝试了print_r($_SERVER);,但对我没有帮助。我希望有一种不同的方法来使用CI。

简单使用,

$this->input->request_headers();

如果您从表单提交发送值,

$_REQUEST will help you
or
    $this->input->post();
    $this->input->get();

从请求头接收所有值

$valuesInHeader = $this->input->request_headers();

从请求头中获取特定值

$hostValueInHeader = $this->input->request_headers()['Host'];
//"Host" is a key of a value, you can use your required key.