PHP headers_list()Funciones


PHP HTTP 参考手册Manual de referencia completo de PHP HTTP

Definición y uso

La función headers_list() devuelve una lista de los encabezados de respuesta enviados (o por enviar).

Esta función devuelve un array que contiene los encabezados.

Sintaxis

headers_list()


Consejos y notas

Consejo:Para determinar si ya se han enviado los encabezados, use la función headers_sent().


Ejemplo 1

<?php
setcookie("TestCookie","SomeValue"');
header("X-Sample-Test: foo");
header('Content-type: text/plain');
?>

<html>
<body>

<?php
// What headers are to be sent?
var_dump(headers_list());
?>

</body>
</html>

El código anterior generará:

array(4)
{
[0]=> string(23) "X-Powered-By: PHP/5.1.1"
[1]=> string(19) "Set-Cookie: TestCookie=SomeValue"
[2]=> string(18) "X-Sample-Test: foo"
[3]=> string(24) "Content-type: text/plain"
}


PHP HTTP 参考手册Manual de referencia completo de PHP HTTP Otras extensiones