Results 1 to 2 of 2

Thread: how to save text in PHP..? need help asap...

  1. #1
    Join Date
    May 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to save text in PHP..? need help asap...

    Hi...

    in PHP code,
    How can I save text? and to read text file and fill in text area?
    can you please share just a piece of code....I really need it..asap!!!

    thanks in advance....

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    To read text (and output to browser):

    Code:
    <?php
     echo file_get_contents('file.txt');
    ?>
    to save text:

    Code:
    <?php
    
     $content = 'This is a test text file saved by using a php script!';
    
     $fp = fopen('file.txt', w);
     fwrite($fp, $content);
     fclose($fp);
    For more information, visit php.net's website and look up the following commands:

    fopen, fwrite, file_get_contents, file

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

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
  •