Click here to Skip to main content
15,889,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is this used as a comment or something or does it create a space between characters which I notice that's what it does. I know it dose not create a line break so why is

there so little info about this? There is so much info on how rather than what this means \n actually. For example

INPUT

PHP
<?php
echo "a\nbc";
echo "abc";
?>


OUTPUT
a bcabc

The only thing I notice is it gives me a space that's all I notice is that what it is good for? Couldn't I just add a space with the space bar and do the same thing why is

this helpful? Please don't just quote from jargon terms. Explain in your own words the most easiest way possible what this does and why would any one use this since it doesn't do any thing magical in output thank you.

What I have tried:

Having a hard time to find info about this on google. Every one is more interested on google on how to use this rather then what this does.
Posted
Updated 15-Jan-18 20:50pm
v2

A new line really depends on the environment you are running your sample on. In Windows, if you want a new line, you would specify a carriage return and line feed \r\n whereas Unix uses \n. Your question makes me think you ran your sample on Windows.
 
Share this answer
 
from this point of view this does not make much sense.
But you can show line break in PRE tag. Also, if you are building console based application this values will reflect.
 
Share this answer
 
Comments
[no name] 16-Jan-18 2:00am    
That's what I said I just want to know what this mean?
Here's what I mean by this video.

https://www.youtube.com/watch?v=2Cd7g26WQVs
 
Share this answer
 
A few people from stackoverflow told me this is use to make your source code more readable thanks for your response guys but the guys from stackoverflow made the most sense to me. The link is here

[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900