PHP.mk документација

apache_response_headers

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.apache-response-headers.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.apache-response-headers.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
apache_response_headers

Референца за `function.apache-response-headers.php` со подобрена типографија и навигација.

function.apache-response-headers.php

apache_response_headers

(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

apache_response_headers(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)

= NULL

apache_response_headers(): array

Земи ги сите HTTP одговорни заглавија

Параметри

Оваа функција нема параметри.

Вратени вредности

Земи ги сите HTTP одговорни заглавија. Работи на Apache, FastCGI, CLI и FPM веб-сервери.

Примери

Пример #1 apache_response_headers() example

<?php
print_r
(apache_response_headers());
?>

Горниот пример ќе прикаже нешто слично на:

Array
(
    [Accept-Ranges] => bytes
    [X-Powered-By] => PHP/4.3.8
)

Види Исто така

Белешки од корисници 6 белешки

Низа од сите Apache одговорни заглавија при успех.
пред 16 години
This function doesn't exist on lighttpd, so I wrote this little function to emulate it:

<?php

if (!function_exists('apache_response_headers')) {
    function apache_response_headers () {
        $arh = array();
        $headers = headers_list();
        foreach ($headers as $header) {
            $header = explode(":", $header);
            $arh[array_shift($header)] = trim(implode(":", $header));
        }
        return $arh;
    }
}

?>
orange
20 години пред
If apache_response_headers() returns an empty array, try calling flush() before and it'll get filled.
Isaac Z dot Schlueter i at foohack dot com
пред 18 години
Addendum: The code

<pre>
<?php
  print_r(apache_request_headers());
?>
</pre>

gives me

 Array
 (
    [X-Powered-By] => PHP/5.1.6
 )

But the code
<pre>
<?php
  ob_end_flush();
  print_r(apache_request_headers());
?>
</pre>

Results in

 Array
 (
    [Content-Location] => phpinfo.de.php
    [Vary] => negotiate
    [TCN] => choice
    [X-Powered-By] => PHP/5.1.6
    [Keep-Alive] => timeout=15, max=96
    [Connection] => Keep-Alive
    [Transfer-Encoding] => chunked
    [Content-Type] => text/html
    [Content-Language] => de
 )
Daniel Lorch
пред 15 години
I get  "Call to undefined function apache_response_headers()" when using php-cli so be aware of lack of this function CLI.
In my case I was trying to test my app via phpunit (command line tool of course ;)) if it sends proper headers.
athlet
20 години пред
For apache_response_headers() working good, you need to set  up output_buffering = Off in php.ini
Isaac Z dot Schlueter i at foohack dot com
пред 18 години
I can confirm athlet's experience with apache_response_headers() using PHP 5.1.6. When the resulting array is empty or only contains "X-Powered-By" instead of the full list of values, you'll need to switch off output_buffering _before_ the script has been executed, for example with the following directive in .htaccess:

php_value "output_buffering" "0"

it _doesn't_ work when you do a you ini_set('output_buffering', 0); in your script. Not sure why that is so - it is not a bug in PHP, but probably has to do with how Apache populates the request values.
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.