Micro Niche Builder
Closed Thread
Results 1 to 5 of 5

Thread: Reading from text file

  1. #1

    Default Reading from text file

    I am making log file in php I am not able to read from that text file, can you tell me how can I read from the text file using php?


  2. Micro Niche Builder

  3. #2

    Default

    You can ready file using fread, you can refer following code for reading a file

    PHP Code:
    $myFile "File.txt";
    $fh fopen($myFile'r');
    $theData fread($fh5);
    fclose($fh);
    echo 
    $theData
    Thanks

  4. The Following User Says Thank You to nikon For This Useful Post:

    harry (07-25-2009)

  5. #3

    Default

    You can use fopen, fread to read from the file and you can print whole file on the screen or convert it to mysql

  6. #4

    Default

    Code:
    $msg="";
    $handle=fopen("file.txt","r");
    while(!feof($handle))
    	$msg = $msg . fgets($handle,4096);
    fclose($handle);
    echo $msg;

  7. #5

    Default

    PHP have file_get_contents function, which returns file content as string.
    $str = file_get_contnets("file.txt")

Closed Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts