Re: [PHP] Line Break Problem
> Hi, > > I have a question regarding using line breaks in PHP. I have the code > something like: > > echo "1" . "\t " . $x . "\t" . $y . "\r\n"; > > When I run the code, it looks like a whole blob of text, but when I use "View > Source", the line breaks are formatted then correctly. > Anyone can please tell me if this is what this is supposed to be? > If so, how can I get the user to see the line break as they are, do I have to > use ? > > Thanks for your help. > Hi Alice, I see that you are using a browser to view the result. Use to cause a break at end of every line. echo "1" . "\t " . $x . "\t" . $y . "\r\n"; that way, the lines are properly break even when viewing the HTML source. Virgil http://www.jampmark.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Line Break Problem
Alice Wei wrote: Date: Mon, 9 Mar 2009 13:28:19 +0100 From: joc...@iamjochem.com To: stut...@gmail.com CC: aj...@alumni.iu.edu; php-general@lists.php.net Subject: Re: [PHP] Line Break Problem Stuart schreef: 2009/3/9 Alice Wei I have a question regarding using line breaks in PHP. I have the code something like: echo "1" . "\t " . $x . "\t" . $y . "\r\n"; When I run the code, it looks like a whole blob of text, but when I use "View Source", the line breaks are formatted then correctly. Anyone can please tell me if this is what this is supposed to be? If so, how can I get the user to see the line break as they are, do I have to use ? you can also wrap the output in question in a tag: 1 X Y 2 X Y alternatively use the nl2br() function ... but that won't help with displaying the tabs. note that there is a difference between the output of your script (which you can view using 'View Source' when the output is sent to the browser) and the representation of that same source (by which I mean how the the source is rendered [in the browser, in this case). HTML rendering ignores tabs, carriage returns and multiple consecutive spaces found in the source (with the exception of the tag, possibly the tag, additionally the CSS attribute 'whitespace', IIRC, can be used to force rendering all whitespace chars. Hi, all: Thanks to all who replied. It looks like that a simple tag works great. Looks like I didn't realize that \r\n does not reflect itself to the screen. Alice _ All-in-one security and maintenance for your PC. Get a free 90-day trial! http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail just a little side-note "\r\n" is windows specific, "\n" is linux but also works in many windows applications - the best option though is to use the php constant PHP_EOL as such which will use the correct end of line terminator for whichever platform your app is on, thus making your scripts portable and saving you future headaches :) echo "1" . "\t " . $x . "\t" . $y . PHP_EOL; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Line Break Problem
> Date: Mon, 9 Mar 2009 13:28:19 +0100 > From: joc...@iamjochem.com > To: stut...@gmail.com > CC: aj...@alumni.iu.edu; php-general@lists.php.net > Subject: Re: [PHP] Line Break Problem > > Stuart schreef: > > 2009/3/9 Alice Wei > > > >> I have a question regarding using line breaks in PHP. I have the code > >> something like: > >> > >> echo "1" . "\t " . $x . "\t" . $y . "\r\n"; > >> > >> When I run the code, it looks like a whole blob of text, but when I use > >> "View Source", the line breaks are formatted then correctly. > >> Anyone can please tell me if this is what this is supposed to be? > >> If so, how can I get the user to see the line break as they are, do I have > >> to use ? > > > > you can also wrap the output in question in a tag: > > > 1 X Y > 2 X Y > > > alternatively use the nl2br() function ... but that won't help > with displaying the tabs. > > note that there is a difference between the output of your script > (which you can view using 'View Source' when the output is sent to > the browser) and the representation of that same source > (by which I mean how the the source is rendered [in the browser, in this > case). > > HTML rendering ignores tabs, carriage returns and multiple consecutive spaces > found in the source (with the exception of the tag, possibly the > tag, > additionally the CSS attribute 'whitespace', IIRC, can be used to force > rendering > all whitespace chars. Hi, all: Thanks to all who replied. It looks like that a simple tag works great. Looks like I didn't realize that \r\n does not reflect itself to the screen. Alice _ All-in-one security and maintenance for your PC. Get a free 90-day trial! http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail
Re: [PHP] Line Break Problem
Stuart schreef: > 2009/3/9 Alice Wei > >> I have a question regarding using line breaks in PHP. I have the code >> something like: >> >> echo "1" . "\t " . $x . "\t" . $y . "\r\n"; >> >> When I run the code, it looks like a whole blob of text, but when I use >> "View Source", the line breaks are formatted then correctly. >> Anyone can please tell me if this is what this is supposed to be? >> If so, how can I get the user to see the line break as they are, do I have >> to use ? > you can also wrap the output in question in a tag: 1 X Y 2 X Y alternatively use the nl2br() function ... but that won't help with displaying the tabs. note that there is a difference between the output of your script (which you can view using 'View Source' when the output is sent to the browser) and the representation of that same source (by which I mean how the the source is rendered [in the browser, in this case). HTML rendering ignores tabs, carriage returns and multiple consecutive spaces found in the source (with the exception of the tag, possibly the tag, additionally the CSS attribute 'whitespace', IIRC, can be used to force rendering all whitespace chars. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Line Break Problem
2009/3/9 Alice Wei > I have a question regarding using line breaks in PHP. I have the code > something like: > > echo "1" . "\t " . $x . "\t" . $y . "\r\n"; > > When I run the code, it looks like a whole blob of text, but when I use > "View Source", the line breaks are formatted then correctly. > Anyone can please tell me if this is what this is supposed to be? > If so, how can I get the user to see the line break as they are, do I have > to use ? This has nothing to do with PHP. HTML does not show carriage returns or repeated white-space. If you want carriage returns or tabs you need to use appropriate tags and/or CSS. -Stuart -- http://stut.net/