Php 如何在不使用html标记的情况下使用换行符?
这是我的代码:Php 如何在不使用html标记的情况下使用换行符?,php,Php,这是我的代码: $blogid = mysql_real_escape_string($_GET['id']); if((isset($_POST['comment']))&&(!(trim($_POST['comment'])==FALSE))&&(isset($_SESSION['userid']))){ $comment = mysql_real_escape_string($_POST['comment']); $querycommen
$blogid = mysql_real_escape_string($_GET['id']);
if((isset($_POST['comment']))&&(!(trim($_POST['comment'])==FALSE))&&(isset($_SESSION['userid']))){
$comment = mysql_real_escape_string($_POST['comment']);
$querycomment = "INSERT INTO `comment` (`userid`, `blogid`, `body`) VALUES ( '".$_SESSION['userid']."', '".$blogid."', '".$comment."');";
$rowchat = mysql_query($querymess,$db_con) or die("Failed: " . mysql_error() );
}
<form method="post" action="blog.php?id=<?php echo $blogid; ?>" >
<textarea name="comment" ></textarea>
<input type="submit" value="send" name="submit" />
</form>
然后在注释列表中出现以下内容:
This is my world
为什么换行符不起作用?因为换行符保存为
\n
您可以在回显字符串之前使用PHP函数
<?php
$string = "This\nis\nmy\nworld";
echo nl2br($string);
?>
因为换行符保存为
\n
您可以在回显字符串之前使用PHP函数
<?php
$string = "This\nis\nmy\nworld";
echo nl2br($string);
?>
类似于“如何在没有HTML的情况下使用HTML”问题您可以将输出包装在标记中类似于“如何在没有HTML的情况下使用HTML”问题您可以将输出包装在标记中