Home > php教程 > php手册 > body text

php自带函数去除html标记

WBOY
Release: 2016-06-06 19:40:17
Original
974 people have browsed it

strip_tags 去掉 HTML 及 PHP 的 标记 。 语法: string strip_tags(string str); 传回值: 字串 函式种类: 资料处理 内容说明 htmlspecialchars 将特殊字元转成 HTML 格式。 语法: string htmlspecialchars(string string); 传回值: 字串 函式种类: 资料处理

 

      strip_tags

  去掉 HTML 及 PHP 的标记

  语法: string strip_tags(string str);

  传回值: 字串

  函式种类: 资料处理

  内容说明

  htmlspecialchars

  将特殊字元转成 HTML 格式。

  语法: string htmlspecialchars(string string);

  传回值: 字串

  函式种类: 资料处理

  本函式将特殊字元转成 HTML 的字串格式 ( &....; )。最常用到的场合可能就是处理客户留言的留言版了。

  & (和) 转成 & 
  " (双引号) 转成 " 
  
  此函式只转换上面的特殊字元,并不会全部转换成 HTML 所定的 ASCII 转换。

  使用范例 
 

  1. $new = htmlspecialchars("Test", ENT_QUOTES);  
  2. echo $new
  3. ?>  

 

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!