0

I have the following issues when trying to get the header using the get_headers() function.

I get the following Warning: get_headers(): This function may only be used against URLs for both code snippets below.

get_headers("file:///C:/wamp64/www/site/index2.php");
get_headers("C:/wamp64/www/site/index2.php");

And this one just loops forever

get_headers("http://localhost/site/index2.php");

I was wondering how can I fix this problem or is there another way I can get the headers if so how and thanks.

juice.gin
  • 71
  • 9

1 Answers1

2

These lines gives you errors because you have to put urls in get_headers function not file paths.

get_headers("file:///C:/wamp64/www/site/index2.php");
get_headers("C:/wamp64/www/site/index2.php");

And below line loops because most probably you're visiting the same url you are giving to get_headers.

get_headers("http://localhost/site/index2.php");
Amir
  • 413
  • 4
  • 13
  • how do I get the files headers? – juice.gin Nov 11 '18 at 10:21
  • it will still loop even if I am not visiting the same URL. – juice.gin Nov 11 '18 at 10:23
  • 1
    headers are for urls. so if there is url equivalent of any files you want, you have to put that in the function not its path on server. if you're writing this function e.g. in `http://localhost/index.php` and you're visiting that url to see the result, you're given url to `get_headers` must be something else than `http://localhost/index.php`. In this case there should be no problem. – Amir Nov 11 '18 at 10:34