Results 1 to 2 of 2

Thread: File write, read, open

  1. #1
    Addicted Member Mr.Joker's Avatar
    Join Date
    Apr 12
    Posts
    140

    File write, read, open

    I am learning today how to open file, write it or read by using PHP. I made some code which is probably wrong since everything I learnd is mixed in my head.
    PHP Code:
    <?php
    $name 
    "text.txt";
    $write fopen($name'w') or die("Can't open file");
    $open fopen($name'r');
    $data "AAAAAAAAAAAAAAA";
    $show fwrite($write,$data);
    $a fgets($open);
    fclose($open);
    echo 
    $open;
    ?>
    There is the problem. I want to create a new file called text.txt . Then I want to write something in ti and finaly after reading in to display that file on the screen. How to do that?

  2. #2
    Moderator
    Join Date
    Jan 05
    Location
    Sydney
    Posts
    13,615

    Re: File write, read, open

    Try:
    PHP Code:
    echo $a 
    not
    PHP Code:
    echo $open 

    Also try using file_put_contents and file_get_contents instead.

Posting Permissions

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