|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Formatting a newline/line break in PHP/HTML output
I'm writing some php stuff and want to check the html output. But it's all written on one line. I've seen in tutorials here where the authors were using something to format the html output of the php so it comes out all neat.
I've tried /n and \n but they aren't working. So my question is how to I get php to format the html output so I can add line breaks into the html output?\ Thanks! |
|
#2
|
|||
|
|||
|
\n should do the trick.
if you are trying to output a textarea, then use nl2br();
__________________
-- Jason |
|
#3
|
|||
|
|||
|
When you are echoing \n remember that it will need parsing so it should be coded as follows:
PHP Code:
Let us know how you do |
|
#4
|
|||
|
|||
|
Just as Taelo said...
Use: echo nl2br($yourTextData); Just do this when showing your data as HTML. ![]()
__________________
The deal is not to know everything, but to know the email of the one who does. |
|
#5
|
|||
|
|||
|
Php_eol
If you are trying to format your HTML source, you should use the constant PHP_EOL. The main reason being that on windows machines the EOL is \r\n and on UNIX machines it is \n. With a properly installed LAMP set up just use PHP_EOL like so.
$html.="<p>This is my HTML</p>" . PHP_EOL; cheers, _Stephen |
|
#6
|
|||
|
|||
|
Quote:
Thanks that was exactly what I needed to output into a javascript array. do { $docount = $docount + 1; echo "'stockthumbs/$pic_array[$docount]',". PHP_EOL; } while ($docount < $count-1); $docount = $docount + 1; echo "'stockthumbs/$pic_array[$docount]'". PHP_EOL; |
|
#7
|
|||
|
|||
|
This comment saved me from a very perplexing problem in Outlook 2007. PHP generated HTML emails would break in a rather random way. What seemed to be happening was that Outlook did not like receiving the HTML as one long unbroken string. So, it would take the liberty of breaking it after a certain point. That might be in the middle of an html tag and break the tag. Thus the html email would not display correctly.
It appears to happen with very long php generated HTML emails. In any case, adding the . PHP_EOL; tag every once in a while solved the problem. like so: body .= "<br>" . PHP_EOL; This is an old thread, but I wanted to re-open it in case it might help someone struggling with this problem as much as me. Kurt Quote:
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Formatting a newline/line break in PHP/HTML output |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|