如何允许文本区域、PHP 到 MySQL 上的 html 标签?
如何允许PHP文本区域内的这些类型的HTML标签进入MySQL?简单的可能... 、
、
等。
谢谢。
How to allow these types of HTML tags inside the textarea for PHP into MySQL? The simple ones maybe... <b>
, <i>
, <u>
etc.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
php函数
strip_tags
可以用于剥离除$allowable_tags
之外的所有 html 标签。可以这样指定:我猜你想要的是这样的东西。然而,这并不能解决需要转义的特殊字符可能出现的问题。
另外:看看HTML Purifier,正如 @Phil 在他的评论中建议的那样。如果您担心 XSS 等等,因为
strip_tags
不会如果您允许某些标签持续存在就足够了。The php function
strip_tags
can be used for stripping all html tags except for$allowable_tags
. Which can be specified like this:I guess it's something like this that you want. However this doesn't solve possible problems with special characters that need to be escaped.
Also: Have a look at HTML Purifier as @Phil suggest in his comment. This is especialy a good idea if you are worried about security loopholes like XSS and such, because
strip_tags
won't be good enough if you allow certain tags to persist.您可以保留 HTML 标签不变,因为 PHP 和 MySQL 都没有问题。从数据库检索数据并将其放入文本区域时,请确保使用
htmlspecialchars()
将具有特殊含义的字符转换为 HTML 实体。例如,
<
将转换为<
。You can leave HTML-tags as is, because both PHP and MySQL don't have problems with that. When retrieving data from the database and place it inside the textarea, make sure to use
htmlspecialchars()
to convert characters with a special meaning to HTML-entities.For example
<
will be converted to<
.