General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

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 October 13th, 2002, 09:55 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
Line Breaks

Question: How can I enter in <br> tags to a form upon submission?

in other words,...this form that I am typing in, if I hit enter 4 times



my text will move down here. How can I do this?

-- Jason

Reply With Quote
  #2  
Old October 13th, 2002, 11:06 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
i think this is what your looking for

$string = nl2br($string);

it converts \n (new line marks) into <br /> tags.

so when you type in a form:

"testing


1.2.3"

it comes out like the way you typed it and not like this

testing 1.2.3
for more information

URL

Reply With Quote
  #3  
Old October 13th, 2002, 11:51 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
ahh yes,....I knew I had seen that function before,....thanks Ben




-- Jason

Reply With Quote
  #4  
Old October 14th, 2002, 12:53 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
np, basically all nl2br() (New Line To Break) does is this

$variable = str_replace("\n","<br />", $variable);

so if you forget it you can use this

also dont forget php.net's searchable manual

Reply With Quote
  #5  
Old October 14th, 2002, 08:00 AM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
yeah, I am always looking in php.nets manual. The problem is I don't know what I am looking for sometimes

Also, can you point me to a site that explains what the <br /> syntax is?

-- Jason

Reply With Quote
  #6  
Old October 14th, 2002, 07:56 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Taelo,

<br> and <br /> do the exact same thing; just that <br /> follows the XHTML standard of closing all non-ending tags.
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #7  
Old October 14th, 2002, 08:05 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
ok,...but I don't understand the purpose... I guess I need to read up xhtml

Reply With Quote
  #8  
Old October 14th, 2002, 09:08 PM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
explanation of xhtml closing rule

the reason that you have to end non-closing tags with / is simply to maintain well-formedness within xml communications, as well as uniformity in html. all xml elements must have a closing tag or it won't parse. all html elements have to have a closing tag with only a few exceptions (<br>, <hr>) etc. In certain cases it's expressly disallowed.
since xml parsers require everything to have a closing element, no exceptions, you have to do something to close off <br> and others. </br> is expressly forbidden; since anything that isn't recognized as a valid html property after a space in a tag is ignored, / is used to close the tag in xml. xml parsers actually looks for a / within <> that isn't in quotes to denote a closing tag, that in addition to the matching variable name.
so by simply adding the / at the end of the tag, xml sees the tag as closed.

Reply With Quote
  #9  
Old October 14th, 2002, 09:44 PM
Taelo Taelo is offline
5B's
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: PC, FL
Posts: 366 Taelo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 59 sec
Reputation Power: 7
great explanation, thank you

Reply With Quote
  #10  
Old October 14th, 2002, 09:58 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Just for the record, you can also close of tags like br like this

<br></br>

as an xhtml parser will also allow this, but its more common to use <br />

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Line Breaks


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 2 hosted by Hostway
Stay green...Green IT