Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.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 正在清除\r\n_Php_Textarea_Newline - Fatal编程技术网

Php 正在清除\r\n

Php 正在清除\r\n,php,textarea,newline,Php,Textarea,Newline,我正在从数据库中打印文本,但我不断得到\r\n,我不完全确定原因。这就是我的代码的样子 form action="portal.php" method="post" class="label-top"> <div> <label for="name">News Message</span></label> <form method="post" action="" name="bio">

我正在从数据库中打印文本,但我不断得到\r\n,我不完全确定原因。这就是我的代码的样子

form action="portal.php" method="post" class="label-top">
    <div>
       <label for="name">News Message</span></label>
        <form method="post" action="" name="bio">
         <textarea name="bio" cols="25" rows="5">


             <?php echo stripslashes($_SESSION['bio']) ?> 


     </textarea><br>
但实际上是这样的

Test\r\nTest 
编辑

在跟踪你们之后,一切似乎都很顺利,直到我发布它。 我认为我的POST方法有问题

如果有人有时间看一下,我将不胜感激

  <?php
include("mysql_connect.php");
session_start();


if( $_SESSION['login'] != 1 ) {
header( 'Location:login.php' ) ;}


if($_SERVER['REQUEST_METHOD'] == 'POST') {
$bio = mysql_real_escape_string($_POST['bio']);
$user_input = mysql_query("UPDATE members SET bio ='$bio' WHERE username='$_SESSION[username]' ");
$_SESSION['bio'] = $bio;
    } 
    if($_SERVER['REQUEST_METHOD'] == 'POST2') {
$bio = mysql_real_escape_string($_POST['notification']);
$user_input = mysql_query("UPDATE members SET notification ='$notification' WHERE username='$_SESSION[username]' ");
$_SESSION['notification'] = $notifiation;
    } 

?>


<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
        <title>APPSTARME</title>
        <link href="css/style.css" rel="stylesheet" type="text/css" />
    </head>
<body>
    <header>
        <div class="logo">
            <a href="login.php">
                <img src="images/logo.png" alt="APPSTARME" />
            </a>
        </div>
        <div class="clear"></div>
    </header>
    <div class="content">
    <article>

<h2 class="underline">Logged in as  <?php echo ucfirst($_SESSION['username']); ?>  </span></h2>

            <form action="portal.php" method="post" class="label-top">
                <div>
                     <label for="name">News Message</span></label>
                     <form method="post" action="" name="bio">
<textarea name="bio" cols="25" rows="5">

<?php
 echo nl2br($_SESSION['bio']); ?> 
</textarea><br>
<input type="submit" value="Update Message" /></form>
                </div>

条带斜杠
不会删除
\r\n

您需要:
preg\u replace(“~\r?\n~”,“
,$string)

您需要
nl2br($\u会话['bio'])

编辑:

由于您应该打印
中的文本,请尝试以下方法:

preg_replace("/\r\n|\r|\n/",'&#13;',$_SESSION['bio']')


是。

这应该可以做到:

<?php 
$string = "Hello\r\nWorld\r\n!\r\n"; 
$string = nl2br($string); 
echo $string;
?>

祝你好运


我建议大家看一看关于你问题的更多信息。

我承认。忘记了这个。文本区域内的

将呈现为

,并且不会导致换行。我很担心你是如何检查你的请求的。。使用$\u POST全局数组代替条件检查请求\u方法。此外,您不应该偏离HTTP。使用POST,并在其中使用条件。当我登录时,不要创建另一个名为post2的方法,一切看起来都正常,但当我使用post方法更新它时,一切都会回到\r\n\n问题
<?php 
$string = "Hello\r\nWorld\r\n!\r\n"; 
$string = nl2br($string); 
echo $string;
?>