我正在用 html 制作一個表單,該表單中有一個<textarea>標簽。first.php 就像:
<form method="post" action="next.php">
<textarea name="desc" raws="4">Here, Its Text Area</textarea>
<button type="submit" name="submit">NEXT BUTTON</button>
</form>
next.php 就像:
<?php
if(isset($_POST["submit"]))
{
$desc = $_POST["desc"];
echo $desc; //<------ ECHO LINE 1
}
else
{
header("location: first.php");
}
當我輸入此訊息時:
Hi,
Helo there,
I am LakshyaK2011.
并在 next.php 中回顯,在回顯第 1 行(請參閱 next.php 的代碼)
它顯示如下:
Hi, Helo there, I am LakshyaK2011.
有什么修復方法嗎?謝謝,
我試過:(
我不知道該怎么做所以我什么也沒試)
我預計:
我將輸入:
Hi,
Helo there,
I am LakshyaK2011.
它會列印出來。
不喜歡:
Hi, Helo there, I am LakshyaK2011.
uj5u.com熱心網友回復:
要以 HTML 格式顯示新行,您需要諸如<br>
所以改變
echo $desc;
至
echo str_replace(chr(13), '<br>',$desc);
或者,使用nl2br()
https://www.php.net/manual/zh/function.nl2br.php
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/535691.html
標籤:PHP网页格式形式
