|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
ahh yes,....I knew I had seen that function before,....thanks Ben
![]() -- Jason |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
ok,...but I don't understand the purpose... I guess I need to read up xhtml
![]() |
|
#8
|
|||
|
|||
|
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. |
|
#9
|
|||
|
|||
|
great explanation, thank you
|
|
#10
|
|||
|
|||
|
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 /> |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Line Breaks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|