views:

217

answers:

2

i using get_headers Function in PHP to request headers from website in local server return arrays put when use in my website Does not return arrays

examples for returns

in local server

Array
(
    [0] => HTTP/1.1 301 Moved
    [Server] => Array
        (
            [0] => nginx/0.7.42
            [1] => Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4
            [2] => Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4
            [3] => Microsoft-IIS/7.0
        )
    [Content-Type] => Array
        (
            [0] => text/html; charset=utf-8
            [1] => text/html; charset=iso-8859-1
            [2] => text/html
            [3] => text/html; charset=utf-8
        )
    [Location] => Array
        (
            [0] => http//3.ly/aXP
            [1] => http//3.ly/aXP/
            [2] => http//stackoverflow.com
        )
    [MIME-Version] => 1.0
    [Content-Length] => Array
        (
            [0] => 277
            [1] => 376
            [2] => 0
            [3] => 122213
        )
)

in real server

Array
(
    [0] => HTTP/1.1 301 Moved
    [Server] => nginx/0.7.42
    [Date] => Sat, 10 Oct 2009 03:15:32 GMT
    [Content-Type] => text/html; charset=utf-8
    [Connection] => keep-alive
    [Location] => http//3.ly/aXP
    [MIME-Version] => 1.0
    [Content-Length] => 277
)

i wont to return arrays

thanks....

A: 

Hi there -

There seems to be a difference in how PHP handles redirects on your local server and on the real server. I think you would get arrays locally too, but for some reason get_headers() locally doesn't seem to follow redirects.

Is the PHP version same in both environments?

Lauri Lehtinen
A: 

thnk you for help

PHP Version in local server 5.2.6 in real server 5.2.8

Testr
This should be a comment to the answer below, not an answer itself.
Nick Presta