php get_headers returns nothing while page exists

1.1k Views Asked by At

I've a big problem. The following code does not return the header, but the page exists:

$withWarning = get_headers("http://www.test.de",1);
print_r($withWarning);

but this works:

    $withWarning = get_headers("https://www.test.de",1);
    // -----------------------------^
    print_r($withWarning);

Both urls (with http and https) are valid...

An other url with no return:

http://code.tutsplus.com/tutorials/create-bookmarklets-the-right-way--net-18154

Could someone please help me to get a header from all urls? Thank you very much.

Greetings Hans

EDIT1) Now I've got the server error file: Warning: get_headers(http://www.test.de): failed to open stream: Permission denied in /var/www/html/test.php on line 10

Does someone know this error and a solution?

1

There are 1 best solutions below

0
On

I know, this is not an error, but too long to copy as comment. This is the first for me.

array
  0 => string 'HTTP/1.1 301 Moved Permanently' (length=30)
  'Content-Type' => 
    array
      0 => string 'text/html; charset=UTF-8' (length=24)
      1 => string 'text/html; charset=utf-8' (length=24)
  'Location' => string 'https://www.test.de/' (length=20)
  'Server' => 
    array
      0 => string 'Microsoft-IIS/8.5' (length=17)
      1 => string 'Microsoft-IIS/8.5' (length=17)
  'Strict-Transport-Security' => 
    array
      0 => string 'max-age=31536000;' (length=17)
      1 => string 'max-age=31536000;' (length=17)
  'Date' => 
    array
      0 => string 'Tue, 09 Dec 2014 15:14:02 GMT' (length=29)
      1 => string 'Tue, 09 Dec 2014 15:14:03 GMT' (length=29)
  'Connection' => 
    array
      0 => string 'close' (length=5)
      1 => string 'close' (length=5)
  'Content-Length' => 
    array
      0 => string '143' (length=3)
      1 => string '45685' (length=5)
  1 => string 'HTTP/1.1 200 OK' (length=15)
  'Cache-Control' => string 'no-cache, no-store, must-revalidate' (length=35)
  'Pragma' => string 'no-cache' (length=8)
  'Expires' => string '-1' (length=2)
  'Set-Cookie' => string 'sid=4osgeuwzthte0mepxrqvc1hr; domain=test.de; path=/; secure; HttpOnly' (length=70)