douhutongvm382381 2012-12-06 10:22
浏览 68
已采纳

或 在php中回显不打印[重复]

Possible Duplicate:
Print newline in PHP in single quotes
Difference between single quote and double quote string in php

$unit1 = 'paragrahp1';
$unit2 = 'paragrahp2';
echo '<p>' . $unit1 . '</p>
';
echo '<p>' . $unit2 . '</p>';

This is displaying (on view source):

<p>paragraph1</p>
<p>paragraph2</p>

but isnt what I’m expecting, not printing the new line, what can be?

  • 写回答

6条回答 默认 最新

  • douyun1860 2012-12-06 10:23
    关注

    PHP only interprets escaped characters (with the exception of the escaped backslash \\ and the escaped single quote \') when in double quotes (")

    This works (results in a newline):

    "
    "
    

    This does not result in a newline:

    '
    '
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?