Insert PHP
[resolved] How to echo a line break? (3 posts)

  1. Parvus
    Posted 1 year ago #

    I'm sure the fault is mine, but I cannot get my PHP script to output a line-break. Instead it outputs the text of whatever line-break character string I attempt. For example:

    echo 'line 1' . '\n' . 'line 2';
    echo 'line 1' . '
    ' . 'line 2';

    These result in:
    'line 1\nline 2'
    'line 1
    line 2'


  2. Parvus
    Posted 1 year ago #

    I knew it was me. Need to use double quotes instead of single for special characters.

    echo 'line 1' . "\n" . 'line 2' works just fine.

  3. Smaandar
    Posted 1 year ago #

    If you didn't want to concatanate strings, you could also just use:

    echo 'line 1. <br /> line 2.';

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Insert PHP
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic