+ 1

how can i have new line in php?

28th Oct 2016, 4:08 PM
Sivaiah Siva
Sivaiah Siva - avatar
6 odpowiedzi
+ 6
Displaying a new line depend on where your script will output 1- If you are using your script to print output on a command line or to write into a file you can use "\n" or "\n\r" escaping characters to generate a new line A common mistake is to use \n inside a single quote pair '\n' which result to print the string \n as it , because echo and printing of string between single quotes will print the string as it is , while using double quotes will result in evaluating of string between double quotes and print the evaluation output Example1(error) : echo 'Hi brother \n How are you ?'; Output: Hi brother \n How are you ? Example2(correct) echo "Hi brother \n How are you ?"; Output : Hi brother How are you ? As \n is an escape character , so it needs to be evaluated to be converted while outputting to a crlf special character 2-If you are using your script to return output to a web page via a browser a new line can be outputted by echoing or printing the html break line tag :<br> Or using the paragraph tag : <p> or using the div tag :<div> Php is a scripting language and the output of a new line depend where your script output will go Happy scripting 😍
30th Oct 2016, 7:02 AM
Mouhammed zein eddine
Mouhammed zein eddine - avatar
+ 1
depends on your host system, but un Unix like systems it is echo "first line\nsecond line"; echo with double quotes (" ") not single (' ') and add new line symbol (\n) (backslash)
28th Oct 2016, 4:28 PM
Eriks Karls
Eriks Karls - avatar
+ 1
\n is use for new line
28th Oct 2016, 5:27 PM
Abhishek Mehta
Abhishek Mehta - avatar
+ 1
\n symbol
28th Oct 2016, 11:00 PM
javad
javad - avatar
0
data antt
28th Oct 2016, 9:55 PM
ainulislam6365
0
Beside \n you can use <br> also
31st Oct 2016, 10:14 AM
Việt Dũng Đặng Quang
Việt Dũng Đặng Quang - avatar