|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with fwrite and fopen
I'm a bit of a newbie with PHP, and was wondering if someone could tell me what the "a", "/r", "/n", "/t", "w" and other similar things mean, when used with either the fwrite or fopen tags.
|
|
#2
|
|||
|
|||
|
take a look at http://uk.php.net/fopen for an explanation, if you dont understand something come back and ask again!
__________________
http://www.phptutorials.cjb.net. go on, give it a click! |
|
#3
|
|||
|
|||
|
I didn't see "/n", "/t" explained in the link? What do they stand for?
|
|
#4
|
|||
|
|||
|
They are string formatting tags, placing a backslash before some letters indicates a formatting command.
\n is newline in *nix (i think it is \r\n in windows, or \n\r) \t is a tab character, so PHP Code:
## bob goat ## n.b. remember this is a newline which will show up in a text file, if you view it in a browser to you will need <br> or <br /> |
|
#5
|
|||
|
|||
|
Cool, that site you gave me was good mattp23.
But say i wanted to open a text file in a <textarea> tag. I then edited what was inside the box. Then I wanted to save what was in the box, without leaving what was there before in the text file. How would I do that? |
|
#6
|
|||
|
|||
|
Is there anyway i can do the same thing as "w", without truncating the file?
|
|
#7
|
|||
|
|||
|
Quote:
To read the contents of a file to a textarea, use mode 'r', then read it into a textarea, then use fclose. Make your changes in the textarea, then fopen with 'w', to wipe the file, then write the new data from the textarea to the file, then close. Traalaa. To open a file for writing without truncating the file, use a+, to open the file for read/write and put the pointer at the end of the file. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Help with fwrite and fopen |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|