how do i write a new line in php?

Posted on 2008-06-09
Last Modified: 2012-06-22
echo $subject.\n.$op1;
why this is not working and how do i i write a new line?
Question by:mgtm3

Expert Comment

ID: 21745361
In order for this to display in a browser, you will need to include the actual HTML to perform a line break.

echo $subject . "<br />" . $op1;

LVL 48

Expert Comment

ID: 21745362
echo $subject."\n".$op1;
the newline char must be enclosed in double quotes
LVL 24

Accepted Solution

glcummins earned 500 total points
ID: 21745364
PHP is designed to generate HTML, so if you are viewing your results in a browser, use the HTML newline: br

 echo $subject."<br />".$op1;

Open in new window

LVL 17

Expert Comment

ID: 21745366
$subject."\n".$op1; or $subject."\n\r".$op1;

Author Closing Comment

ID: 31465497
this is the only one that worked

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Parts and Products table schema in mysql 6 43
Problem with Simple PHP/mySQL Query 3 51
Echo images using file system 2 29
PHP_POST() error message 9 39
Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now