php 去除html标记--strip_tags与htmlspecialchars的区别详解
strip_tags
去掉 HTML 及 PHP 的标记。
语法: string strip_tags(string str);
传回值: 字串
函式种类: 资料处理
内容说明
本函式可去掉字串中包含的任何 HTML 及 PHP 的标记字串。若是字串的 HTML 及 PHP 标签原来就有错,例如少了大于的符号,则也会传回错误。而本函式和 fgetss() 有着相同的功能。
htmlspecialchars
将特殊字元转成 HTML 格式。
语法: string htmlspecialchars(string string);
传回值: 字串
函式种类: 资料处理
本函式将特殊字元转成 HTML 的字串格式 ( &....; )。最常用到的场合可能就是处理客户留言的留言版了。
& (和) 转成 &
" (双引号) 转成 "
> (大于) 转成 >
'' (单引号) 转成 '
此函式只转换上面的特殊字元,并不会全部转换成 HTML 所定的 ASCII 转换。
复制代码 代码如下:
$new = htmlspecialchars( "Test" , ENT_QUOTES);
echo $new ;
?>
结果: Test

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor