PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 4th, 2005, 04:03 AM
Shaunyboy Shaunyboy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 21 Shaunyboy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 45 m 10 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old January 4th, 2005, 06:03 AM
mattp23 mattp23 is offline
Moderated
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: UK
Posts: 82 mattp23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 44 sec
Reputation Power: 6
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!

Reply With Quote
  #3  
Old January 5th, 2005, 04:05 PM
Faylaricia Faylaricia is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Houston, TX
Posts: 12 Faylaricia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Red face "/n", "/t"

I didn't see "/n", "/t" explained in the link? What do they stand for?

Reply With Quote
  #4  
Old January 5th, 2005, 06:30 PM
mattp23 mattp23 is offline
Moderated
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: UK
Posts: 82 mattp23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 44 sec
Reputation Power: 6
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:
echo "##\nbob\n goat\n##"
would output:
##
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 />

Reply With Quote
  #5  
Old January 7th, 2005, 05:05 PM
Shaunyboy Shaunyboy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 21 Shaunyboy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 45 m 10 sec
Reputation Power: 0
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?

Reply With Quote
  #6  
Old January 18th, 2005, 03:42 AM
Shaunyboy Shaunyboy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 21 Shaunyboy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 45 m 10 sec
Reputation Power: 0
Is there anyway i can do the same thing as "w", without truncating the file?

Reply With Quote
  #7  
Old January 18th, 2005, 05:13 AM
mattp23 mattp23 is offline
Moderated
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: UK
Posts: 82 mattp23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 43 m 44 sec
Reputation Power: 6
Quote:
Originally Posted by Shaunyboy
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?

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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Help with fwrite and fopen


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT