Hello,
When I write this (inside php tags off course)...
echo "Hello, World\n" ;
echo "Hello, Giannis\n" ;
I get this result...
Hello, WorldHello, Giannis
I would expect...
Hello, World
Hello, Giannis
It seems that my escape char for new line (\n) is not working properly? Something wrong with "rpidPHP" or my coding???
BR
Lars
\n does apparently not work
Moderator: kfury77
Forum rules
Please try to follow these guidelines. This will help to receive faster and more accurate response.
Please try to follow these guidelines. This will help to receive faster and more accurate response.
- Check the Support section of the corresponding product first. Chances are you will find your answer there;
- Do not create new topics for already reported problems. Add your comments to the existing topics instead;
- Create separate topic for each problem request. Do NOT post a number of non-related problem reports in a single topic;
- Give your topic a meaningful title. Titles such as "A question," "Bug report" and "Help!" provide others no clue what your message is about;
- Include the version number of the software you are using;
- This is not an official customer support helpdesk. If you need a prompt and official response, please contact our support team directly instead. It may take a while until you receive a reply in the forum;
When you echo \n in PHP it does create a newline.
If the echo was going to a text file for example, you would see it no problem.
When the PHP is outputting to a browser the newline is still there, and can be seen if you view source, but it will show as a space on the page in your browser as newlines are not rendered in HTML, so you have to use the html code for a newline which is <br>
As a quick example create an HTML file with this code:
Now even though you have a newline between the 1, 2 & 3 in the code, when viewed in your browser you will see 1 2 3 all on one line with spaces in between.
To get each number onto a new line you need to do:
or even
If the echo was going to a text file for example, you would see it no problem.
When the PHP is outputting to a browser the newline is still there, and can be seen if you view source, but it will show as a space on the page in your browser as newlines are not rendered in HTML, so you have to use the html code for a newline which is <br>
As a quick example create an HTML file with this code:
Code: Select all
<html>
<body>
1
2
3
</body>
</html>
To get each number onto a new line you need to do:
Code: Select all
<html>
<body>
1<br>
2<br>
3<br>
</body>
</html>
Code: Select all
<html>
<body>
1<br>2<br>3<br>
</body>
</html>
RapidPHP has it's own built in webserver, but you'll need to install PHP:larshgf wrote:Thanks for good answers!
BTW - in which way can I see the PHP generated HTML source in rapid PHP?
http://www.forums.blumentals.net/viewtopic.php?t=2384
That will still show as a space in the rendered HTML rather than an actual line break.jerm wrote:Try using \r\n (carriage return plus newline). It works for me.
The above sample code I posted I tested on our Windows server which uses \r\n for and will still show a space in the browser.