How can you understand what address is localhost from the server that was ordered from a host, and is not located on your PC.

I will describe the situation: upload the file "robots.txt" to the main directory of one of the sites (the file is not empty), then upload the file "test.php" to the directory of the same site, the contents of which are:

<?php file_get_contents('http://localhost/var/www/user/data/www/moywebsite.ru/robots.txt'); ?> 

Gives an error message:

 PHP Warning: file_get_contents( http://localhost/var/www/user/data/www/moywebsite.ru/robots.txt) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: Connection refused in /var/www/user/data/www/ moywebsite.ru/test.php on line 1 

How to get the contents of a robots.txt file without resorting to file_get_contents ('http://moywebsite.ru/robots.txt')? Those. I'm interested in the file_get_contents ('http: // localhost / *') option.

    1 answer 1

    And something like:

    $file = fopen("$_SERVER[DOCUMENT_ROOT]/ robots.txt ","r"); $cnt = fread ($file, 1024); echo $cnt;


    $file = file_get_contents("$_SERVER[DOCUMENT_ROOT]/ robots.txt ");

    Not okay?