简体   繁体   English

字符串文本中的新行

[英]new line in string text

So i'm making something and i dont know how to make new line in php i've tried using nl2br but its giving me Template Error 所以我正在做一些事情,我不知道如何在php中制作新行,我尝试使用nl2br但是它给了我Template Error

错误

This is how it looks without new line 这是没有换行的样子

在此处输入图片说明

it says 它说

Cadilab
AdministratorOnline

and it should be 它应该是

Cadilab Administrator
Online

This is the code: 这是代码:

    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>

            ';

For this code, you can either use <br/><br/> : 对于此代码,您可以使用<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>

OR use "\\r\\n" (enclosed with double quotes, instead of '\\r\\n' ): 或使用"\\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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM