WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Parvus
    Member
    Posted 7 months 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:

    [insert_php]
    echo 'line 1' . '\n' . 'line 2';
    echo 'line 1' . '
    ' . 'line 2';
    [/insert_php]

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

    http://wordpress.org/plugins/insert-php/

  2. Parvus
    Member
    Posted 7 months 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
    Member
    Posted 5 months ago #

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

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

Reply

You must log in to post.

About this Plugin

About this Topic

Tags