Online Shopping : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

63 of 90 people (70%) answered Yes
Recently 8 of 10 people (80%) answered Yes


I need to read a text file & display the contents on the web page from which the php script executed

Mar 15th, 2008 18:16
ha mo, Philip Olson, Marshall Bowling,

There are many ways to do this.  If you're simply dumping text (and not
processing it) then use readfile()
If your file contains valid PHP code and you want it processed, one of
the include functions will do this:
    include 'somefile.ext';
If you want the contents of the file into a string or an array, use
either file() or file_get_contents():
    $filename = 'somefile.ext';
    $array_of_lines   = file($filename);
    $string_from_file = file_get_contents($filename);
See also the manual entries for details:
Note that the above functions may also work through HTTP (URLS).