Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 保持文本格式_Php_Text - Fatal编程技术网

Php 保持文本格式

Php 保持文本格式,php,text,Php,Text,我在使用以下代码保持文本区域中输入内容的格式时遇到问题: <div class="col-md-12"> <h1> <span class="glyphicon glyphicon-pencil"></span> Make a new Paste </h1> <form method="post" action="pastenew.php">

我在使用以下代码保持文本区域中输入内容的格式时遇到问题:

<div class="col-md-12">
        <h1>
            <span class="glyphicon glyphicon-pencil"></span> Make a new Paste
        </h1>
        <form method="post" action="pastenew.php">
            <div class="panel panel-success">
                <div class="panel-heading">
                    <input type="text" name="title" placeholder="Paste Name" class="form-control input-title" value required>
                </div>
                <div class="panel-body">
                    <textarea rows="10" name="paste" placeholder="Insert your paste here" class="form-control input-paste" style="margin-top: 0; margin-bottom: 10px; height: 214px;" value required></textarea>
                    <div class="pull-left">
                        <button class="btn btn-success" type="submit">Submit Paste</button>
                        <button class="btn btn-danger" type="reset">Reset</button>
                    </div>
                </div>
            </div>
            <div class="alert alert-danger" style="font-size: 18px; text-align: center;">Still in development, come back later!</div>
        </form>
    </div>

做一个新的浆糊
提交粘贴
重置
还在开发中,稍后再来!
当我按下submit键时,它会打开一个新页面,我要测试的所有内容是否正常:

<!DOCTYPE HTML>
<html>
<body>
<?php echo $_POST["title"];?><br>
<?php echo $_POST["paste"];?>
</body>
</html>


但是,我没有格式化文本,而是将其全部放在一行中。有办法解决这个问题吗?

尝试使用nl2br()



在输出周围使用
标记。使用或正确操作现在我有一个问题,如果粘贴是HTML或PHP或某些web编程语言,它会显示它而不是文本。@user3241491好吧,你不能同时拥有这两个…现在我在文本安装上遇到问题,它会显示HTML例如:我能做些什么来将它显示为文本?
<?php echo nl2br($_POST["title"]); ?>
<?php echo nl2br($_POST["paste"];) ?>