Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8704901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:13:35+00:00 2026-06-13T03:13:35+00:00

I was trying to add a line break for a sentence, and I added

  • 0

I was trying to add a line break for a sentence, and I added /n in following code.

echo "Thanks for your email. /n  Your orders details are below:".PHP_EOL;
echo 'Thanks for your email. /n  Your orders details are below:'.PHP_EOL;

For some reasons, the I got server error as the result. How do I fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:13:37+00:00Added an answer on June 13, 2026 at 3:13 am

    \n is a line break. /n is not.


    use of \n with

    1. echo directly to page

    Now if you are trying to echo string to the page:

    echo  "kings \n garden";
    

    output will be:

    kings garden
    

    you won’t get garden in new line because PHP is a server-side language, and you are sending output as HTML, you need to create line breaks in HTML. HTML doesn’t understand \n. You need to use the nl2br() function for that.

    What it does is:

    Returns string with <br /> or <br> inserted before all newlines (\r\n, \n\r, \n and \r).

    echo  nl2br ("kings \n garden");
    

    Output

    kings
    garden
    

    Note Make sure you’re echoing/printing \n in double quotes, else it will be rendered literally as \n. because php interpreter parse string in single quote with concept of as is

    so "\n" not '\n'
    

    2. write to text file

    Now if you echo to text file you can use just \n and it will echo to a new line, like:

    $myfile = fopen("test.txt", "w+")  ;
    
    $txt = "kings \n garden";
    fwrite($myfile, $txt);
    fclose($myfile);
     
    

    output will be:

    kings
     garden
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a line break with the Find function in eclipse -
Possible Duplicate: How to add a line break in an Android TextView? I'm trying
I am trying to add a line break in the TextView. I tried suggested
I am trying to add a variable to my log line through my settings.py
I'm trying to add upshot goodness to an existing MVC project. On the line
I am trying a very simple override. I just want to add one line
I am trying add picture boxes dynamically. My code is as PictureBox picture =
Trying to add email notification to my app in the cleanest way possible. When
If I create a new project in netbeans and add a line break, Xdebug
I am actually trying to put a line break in a string in an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.