PHP文本字段段落

时间:2014-11-18 18:18:27

标签: php textfield

是否可以在“Text-field PHP”中添加段落,即输入内容并使用shift-enter作为段落提交,然后在帖子的各自段落中显示....

任何建议都会非常感激。

嗨,脚本是文本字段而不是文本区域。

这也是聪明的PHP

1 个答案:

答案 0 :(得分:0)

<?php
//retrieve the textarea value, assuming the form has a textarea named "textfield"
$text = $_REQUEST['textfield'];

//sanitize the text for showing it to the user
$sanitized_text = html_entities($text);

//replacing the new lines from text to <br>
$final_text = nl2br($sanitized_text);

//showing the text to the user, with "paragraphs"
echo '<p>'.$final_text.'</p>';
?>