所以我正在制作一些东西而且我不知道如何在php中创建新行我尝试使用nl2br
但它给了我Template Error
这是没有新行
的样子它说
Cadilab
AdministratorOnline
它应该是
Cadilab Administrator
Online
这是代码:
echo '
<div id="profileview">
<div class="cat_bar">
<h3 class="catbg">
<span class="ie6_header floatleft"><img src="', $settings['images_url'], '/icons/profile_sm.gif" alt="" class="icon" />', $txt['summary'], '</span>
</h3>
</div>
<div class="covernebitno">
<div class="avatar-profil"><a href="/index.php?action=profile">', $context['member']['avatar']['image'], '</a></center></div>
<div class="usercover">
<div class="informacije">
<p>'.$context['member']['name'].'</br><span class="bojeipticice">'.nl2br((!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']). '\r\n' .$context['member']['online']['text']) .'</p>
<img src="http://i.imgur.com/U0TijfL.jpg" />
<div class="covernebitno">
</div></div>
';
答案 0 :(得分:1)
对于此代码,您可以使用<br/><br/>
:
<p>' . $context['member']['name'] . '</br><span class="bojeipticice">' . nl2br((!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']) . '<br/><br/>' . $context['member']['online']['text']) . '</p>
或使用"\r\n"
(用双引号括起来,而不是'\r\n'
):
<p>' . $context['member']['name'] . '</br><span class="bojeipticice">' . nl2br((!empty($context['member']['group']) ? $context['member']['group'] : $context['member']['post_group']) . "\r\n" . $context['member']['online']['text']) . '</p>