Welcome to the Graphic and Web Design Forum


your forum for all things Design


  •  » Graphic Design
  •  » Web Design
  •  » Logos and Branding
  •  » Illustration
  •  » Photography
  •  » Design Tutorials
  •  » Plenty of Off Topic Chat

Register now to remove this ad box


YES! I want to register an account for free right now!


-->
Page 1 of 2 12 Last
  1. #1

    Line breaks in PHP


    REGISTER TO REMOVE ADS


    Does anyone know how to put line-breaks in PHP content?
    I
    have a Flash contact form that send data to a PHP post script. That then send s the info to an e-mail account, but when it gets there the info doesn't have any breaks.

    Is there a way to put breaks in the content that the e-mail shows? Please help.
    Also, if you could show me an example it would help because Im not to familiar with PHP syntax. Sorry for asking for so much. Please help!

    Thanks much
    I do websites at thestudio23.net

  2. #2
    Russlock's Avatar
    Join Date
    Jan 2007
    Location
    Middlesbrough, Teesside
    Posts
    279
    I think it's something like this to force a line feed.

    "\n"
    It's not what you know or who you know, it's what you know about who you know !!!

    Website design you CAN afford

  3. #3

  4. #4
    If you are using double quotes (") around your body content, you can use \n for a line break. However, if you are using single quotes (') around your body, you can simply enter a line.

    Example (")
    $body = "Line One\nLine Two";
    This would come out as:
    Line One
    Line Two

    Example (')
    $body = 'Line One
    Line Two';
    This would also come out as:
    Line One
    Line Two

  5. #5

    Line break in PHP

    To create a line break in PHP, all you have to do is put the code

    '<br>'

    in the echo statement.

    Check out this tutorial:
    How to Create a Line Break in PHP

  6. #6
    rossable's Avatar
    Join Date
    Oct 2007
    Location
    Columbus, Ohio, United States
    Posts
    2,099

    My Social Networking

    Follow rossable On Twitter Add rossable on Facebook Add rossable on Google+
    Add rossable on Linkedin Visit rossable's Youtube Channel
    Quote Originally Posted by dlhylton View Post
    To create a line break in PHP, all you have to do is put the code

    '
    '

    in the echo statement.

    Check out this tutorial:
    How to Create a Line Break in PHP
    invalid.

    depending on the DTD it may need a space/ before the close.

    the real question is if the line break is content or styling... style should always be done with CSS. content should technically be done with p tags.

    web standards, look 'em up!
    website | not a website - great design forces grokking.

  7. #7
    wayneambler's Avatar
    Join Date
    Jul 2011
    Location
    Leeds, West Yorkshire
    Posts
    23
    Yes, as said previously the code for a line break is simply \n - an example of this for use in a contact form would be:

    $msg = "Name: ".$_POST["name"]."\n";
    $msg .= "E-Mail: ".$_POST["email"]."\n";
    $msg .= "Comment: ".$_POST["comment"]."\n";
    Wayne Ambler : Freelance Web Designer & Developer @ Darkstone Designs
    Visit my Website or Follow me on Twitter

  8. #8

    REGISTER TO REMOVE ADS


    Use the nl2br() function which inserts HTML line breaks (<br />) in front of each newline (\n) in a string. Try this function to break a sentences.

    Code:
    <?php
    echo nl2br("One line.\nAnother line.");
    ?>
    Output:
    Code:
    One line.
    Another line.
    For more information, look at this: http://php.net/manual/en/function.nl2br.php
    Last edited by James_Smith; 15-10-2012 at 10:32 AM.

Page 1 of 2 12 Last

Similar Threads

  1. anna-om-line
    By Toon in forum Illustration Graphic Design
    Replies: 3
    Last Post: 25-02-2009, 12:59 PM
  2. On-Line Invoicing
    By Picha in forum Graphic Design Business Forum
    Replies: 2
    Last Post: 14-02-2008, 12:01 PM
  3. Which Tag Line??
    By Toon in forum Graphic Design and Web Design Help
    Replies: 17
    Last Post: 02-10-2007, 01:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Log in

Log in