摆脱\ r \n

Iam*_*tar 1 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">
         <textarea name="bio" cols="25" rows="5">


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


     </textarea><br>
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用striplashes但它不起作用

我希望我的文字能像这样打印出来

Test
Test
Run Code Online (Sandbox Code Playgroud)

但它反过来就是这样

Test\r\nTest 
Run Code Online (Sandbox Code Playgroud)

编辑

跟随你们之后,一切似乎都很好,直到我发布它.我认为我的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>
Run Code Online (Sandbox Code Playgroud)

Val*_*yev 6

你需要 nl2br($_SESSION['bio'])

编辑:

既然你应该在里面打印文本<textarea>,试试这个:

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

&#13;回程.