开发者

How to best create breaks in a comment using PHP/MYSQL?

I've tried searching for this, but no luck. I have programmed a comment system using PHP and MYSQL and I am having problems displaying comments that users have breaked using enter. I currently have 开发者_如何学JAVAhtml blocked from all comments in order to submit a sanitized entry into MYSQL so they cannot use <br> or anything like that.

I guess my question is this: Are there any special techniques to allow more freedom in the comments users post, especially if they hit enter for a break?


You can use nl2br for this. Check the manual for more details.


You can do a

$input = str_replace("\n", "<br />", $input);

To manually put in the breaks before inputting to the database. Just make sure this happens after any strip_tags or other validation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜