Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2012
    Posts
    51
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Can fwrite() write into, rather over?

    Hi all,


    I have fwrite() writing to a text file called 'numbers.txt'. The text file content is "23".

    I learn't fwrite() from the manual, so did:
    PHP Code:
    f$fp fopen('/opt/numbers.txt''w');
    fwrite($fp'1');
    fclose ($fp); 
    I have used fwrite() to try and make the file content "123", but fwrite() writes over the content of the file, resulting in it just containing "1".

    I couldn't find anywhere about writing into, rather over, and hoping someone could please help me out.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,859
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    $fp = fopen('/opt/numbers.txt', 'w');
    Read the manual (http://php.net/fopen) regarding the different usages of the second parameter (mode)
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Feb 2012
    Posts
    51
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Hi. You were unable to assist, but thank you for trying.

  • #4
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,302
    Thanks
    4
    Thanked 204 Times in 201 Posts
    He helped you Noonga. Did you read the page he suggested you read? The use of W in your fopen will destroy the file. Something you would have discovered if you'd followed the link.
    Dave .... HostMonster for all of your hosting needs


  •  

    Posting Permissions

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