/r Carriage Return not working |
|
Using the HTML, <br /> instead of the "\r" seems to work--
so-- when do you use the "\r" for return or the "\n for new line? |
||||||||||||
|
|
We all have to start somewhere with a new language
The problem you have here isn't actually PHP related, but HTML. Both \r and \n work as you'd expect in PHP itself, for example, from a console window, try:
and you'll get:
Same as if you run a PHP script a non-web environment. HTML however, requires tags rather than escape codes, and that's why '<br />' works for you there rather than a \n or \r. I assume you're running the code in a web environment, and although you're echoing data from PHP, it's actually being rendered by the HTML engine. If you really want to use \r or \n in a web environment, you'll need to either wrap the 'echo' statement(s) in <pre></pre> tags, or define a text content type ( header('Content-type: text/plain'); ). Different situations / results that you're looking for would depend on what method was actually required, but if you're looking to generate HTML output, just continue with the '<br />' tag and all will be well Just FWIW.. PHP also comes with a 'nl2br()' function that will convert newline codes to '<br />' tags. Useful when reading plain text in to display as HTML (for example, a basic news article stored in a database with no HTML tags or parsing a plain text document etc). HTH Regards, Ian |
||||||||||||||||
|
/r Carriage Return not working |
|
||
Content © NuSphere Corp., PHP IDE team
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by
Powered by phpBB © phpBB Group, Design by phpBBStyles.com | Styles Database.
Powered by