我正在尝试在PHP中进行论坛。
我有问题。我有一个带有文本方面的发布表格。想像一下我填补了这一切。
当我在数据库中使用NL2BR时,将换行线路(按Space Bar)时,添加了< br>
标签。但是,当我只输入并且存在自动折线时,就没有< br>
。
我该怎么做,例如,在100个字符的末期,有一个自动线路休息(在数据库中添加了< br>
。我已经在JavaScript中尝试过 答案。
't找到
了正确的
在数据库中
没有
png“ rel =”数据库中的nofollow noreferrer>
问题:
I'm trying to do a forum in php.
I have a problem. I have a publish form with a textarea. Let's imagine that I fill it all.
When I make a line break (when I press space bar), with nl2br, in my database there are <br>
tags added. But when I just type and there is an auto line break, there is no <br>
.
How can I do to, for example, at the end of 100 chars, there is an auto line break (that adds a <br>
in the database. I've tried in Javascript but I didn't found a correct answer.
With
with <br>
In the database
Without
auto line break in textarea (no <br>
)
in the database
Problem:
in the forum (text outside of the div
发布评论
评论(1)
关于PHP的第一部分,我现在还创建了PHP网站,但它是社交媒体,在这里我如何进行销售线路,并逃避
“
”或> \
之类的字符我的聊天和文字太久
尝试这些,
但是如果您想完全具有与用户键入的相同的线路断路,那么简单地不使用CSS Word break并替换写下此
$ letter = join(“&lt; br&gt;”,explode(“ \ \) r \ n“,$ letter)));
而不是$ letter = join(“”,Explode(“ \ r \ n”,$ letter));
或您可能需要<代码> $ letter = join(htmlspecialchars(“&lt; br&gt;“),爆炸(“ \ r \ n”,$ letter)); >
First part about PHP, I am also creating PHP website now but it's social media, and here how I did to make line breaks and also to escape chars like
"
or\
in my chat.and about the text too long
try these
But if you want to exactly have the same line-breaks which user typed, then simply don't use CSS word break and replace write this
$letter = join("<br>", explode("\r\n", $letter));
instead of$letter = join("", explode("\r\n", $letter));
or you may need
$letter = join(htmlspecialchars("<br>"), explode("\r\n", $letter));