0
我對web開發相對較新。我有一個簡單的文本輸入和HTML提交按鈕。從php輸入文字獲取CRLF
<div>
<input type="text" name="sender" id="sender" class="form-control" placeholder="" />
<input type="submit" class="btn-u btn-u-small" name="send" value="Send email" />
</div>
我得到了php中的文本輸入值和echo
它。
<?php
if(isset($_POST["send"]))
{
echo $_POST["sender"] . " \r\nThis was a test";
}
?>
現在我在文本輸入中輸入\r\nUser input
。我打算在echo
命令看起來像:
echo "\r\rUser input." . " \r\nThis was a test."
而且顯示的時候,應該是這樣的:
User input. This was a test.
代替第一\r\n
打印,因爲它是隻有第二\r\n
被解釋爲CRLF
。
\r\nUser input. This was a test.
我試過'\r\n' "\r\n" \\r\\n
但似乎沒有工作。
注意:我不想在html中實際換行,我知道在html換行符是<br />
。我想在PHP字符串中換行。
您是否嘗試過'echo nl2br(「用戶輸入。\ n這是一個測試」);'? (在這裏找到:[http://stackoverflow.com/questions/12994769/how-to-add-a-line-break-within-echo-in-php](http://stackoverflow.com/questions/12994769/如何在php中添加一行內部回顯)) – danny
@danny該代碼是演示php mail()漏洞的示例程序的一部分。我無法在代碼中添加任何其他內容。我只能通過在HTML文本輸入中輸入值來與它交互。 – zindarod
好的,html實體呢?例如' '換行符? – danny