Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

789 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