$text1="http://www.site.com/test.txt";
$text2=file($text1,FILE_IGNORE_NEW_LINES);
print_r($text2);

the above dont print anything,only empty page, although i upload test.txt file to a server and write the URL at above

at where i do wrong, can anyone tell me pls.?

thx

    Test this instead:

    var_dump(file("http://www.site.com/test.txt",FILE_IGNORE_NEW_LINES));
    

      using your code the page says ;

      bool(false)

        There you go, as long as you get false there is probably something wrong with your filepath. 🙂

          file path is true, there is nothing false at the file path

            When the function returns false, there is something wrong with your file or filepath. Try with a different file and try with a relative path instead.

              i suspect the problem is the wrappers:

              A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide.

              http://php.net/manual/en/function.file.php

                I suspect you should enable display_errors and set error_reporting to E_ALL rather than trying to guess (or wait for us to guess) at what the problem is.

                (I also suspect dagon's suspicions may be correct, however.)

                  Thank you very much dagon and bradgrafelman.
                  Both of you are correct.

                  i enabled display_errors and error_reporting to E_ALL as bradgrafelman's suspect then saw the errors;

                  Warning: file() [function.file]: URL file-access is disabled in the server configuration in ...
                  Warning: file(http://www.site.com/test.txt) [function.file]: failed to open stream: no suitable wrapper could be found in ...

                  Then read the Supported Protocols and Wrappers for links to information .. as dagon's suspect,

                  then solved the problem by applying allow_url_fopen to be enabled at php.ini.

                  Now everything is Ok and print_r function worked.

                  Thanks again.

                    Write a Reply...