【asp.ne去除html的函数代码】教程文章相关的互联网学习教程文章

PHP用tidy_parse_file()函数提取HTML中的链接

function dump_urls(tidy_node $node, &$urls = NULL) { $urls = (is_array($urls)) ? $urls : array(); if(isset($node->id)) { if($node->id == TIDY_TAG_A) { $urls[] = $node->attribute['href']; } } if($node->hasChildren()) { foreach($node->child as $child) { dump_ur...

加强版的htmlspecialchars函数

//取消html代码function shtmlspecialchars($string) {if(is_array($string)) {foreach($string as $key => $val) {$string[$key] = shtmlspecialchars($val);}} else {$string = preg_replace(‘/&((#(\d{3,5}|x[a-fA-F0-9]{4})|[a-zA-Z][a-z0-9]{2,5});)/’, ‘&\\1′,str_replace(array(‘&’, ‘”‘, ‘’), array(‘&’, ‘"’, ‘<’, ‘>’), $string));}return $string;}?>

PHP过滤HTML代码空格,回车换行符的函数

PHP 过滤html代码空格,回车换行符的函数 /** * PHP 过滤HTML代码空格,回车换行符的函数 * echo deletehtml() */function deletehtml($str){$str = trim($str);$str=strip_tags($str,"");$str=preg_replace("{\t}","",$str);$str=preg_replace("{\r\n}","",$str);$str=preg_replace("{\r}","",$str);$str=preg_replace("{\n}","",$str);$str=preg_replace("{ }","",$str);return $str;}

php生成静态页面函数(php2html)的例子

/**------------------------Function: php2html($in_Url, $out_htmlFile, $out_logFile)------------------------@ Description: 生成静态函数@ Copyright: Copyright (c) 2006 - 2011@ Create: 2006-08-01@ Modify: 2013-02-16@ 提示:路径为服务器绝对路径; 若给定的路径目录不存在则自动创建@ Example:php2html("http://bbs.it-home.org", "/www/html/index.html", "/www/log/log.txt");*/// {{{ contentsfunction php2html($i...

去除HTML标记,javascript代码的小函数

function trip_html( $html, $len ) {// $html 应包含一个 HTML 文档。// 本例将去掉 HTML 标记,javascript 代码// 和空白字符。还会将一些通用的// HTML 实体转换成相应的文本。$search = array (“‘’si”, // 去掉 javascript“‘]*?>’si”, // 去掉 HTML 标记“‘([\r\n])[\s]+’”, // 去掉空白字符“‘&(quot|#34);’i”, // 替换 HTML 实体“‘&(amp|#38);’i”,“‘&(lt|#6...

php转换html为txt文本的函数代码

/** * 转换html为txt文本的函数 * Edit bbs.it-home.org * at 2013/5/11*/function html2text($str){ $str = preg_replace("//is", "", $str); $str = preg_replace("//is", "", $str); $str = preg_replace("//i", "\n", $str); $str = preg_replace("//i", "\n\n", $str); $str = preg_replace("//i", "\n", $str); $str = preg_replace("//i", "\n", $str); $str = preg_replace("//i", "\n", $str); $st...

php清理word产生的html的函数【图】

在使用FCKedior或ueditor时,从word中粘贴过来的内容,会产生很多额外的标签,本文分享一个清理这种多出的html代码的函数,有需要的朋友参考下。说明: 使用FCKedior或ueditor时,从word中粘贴过来的,会产生好多额外的标签。 本节分享一例代码,用于清除word产生的html代码。例子:<?php /** * 清理word产生的html * by bbs.it-home.org */ function strip_word_html($text, $allowed_tags = ) { mb_regex_encoding(UTF-8); $sear...

PHP压缩html的函数代码

<?php//函数名: compress_html//参数: $string//返回值: 压缩后的$string//by bbs.it-home.orgfunction compress_html($string) { $string = str_replace("\r\n", , $string); //清除换行符 $string = str_replace("\n", , $string); //清除换行符 $string = str_replace("\t", , $string); //清除制表符 $pattern = array ( "/> *([^ ]*) *</", //去掉注释标记 "/[\s]+/", ...

php替换html内容的小函数

<?php/*** 替换html内容* by bbs.it-home.org*/function htmlsp($a){ if(strpos($a, <, 0)===false) { echo $a; }else { while(strpos($a, <, 0)>=0) { if(strpos($a, <, 0)===false) break; $x1 = strpos($a, <, 0); $x2 = strpos($a, >, 0); if($x2===false) //if 特殊需要,因为内容可能只有<开始,没有>结束 $x2 = strlen($a); $t = substr($a, $x1, $x2 - $x1 + 1); $a = str_replace($t,,$a); } ech...

php去掉html标签函数代码

<?phpfunction noHTML($content){ $content = preg_replace("/]*>/i",, $content); $content = preg_replace("/<\/a>/i", , $content); $content = preg_replace("/]*>/i",, $content); $content = preg_replace("/<\/div>/i",, $content); $content = preg_replace("/<font[^>]*>/i",, $content); $content = preg_replace("/<\/font>/i",, $content); $content = preg_replace("/<p[^>]*>/i",, $content); ...

PHP函数strip_tags(去除html)的bug

<?php//解决strip_tags的bugfunction fixtags ($text) {$text = htmlspecialchars($text);$text = preg_replace("/"/", ""\"", $text);$tags = "/<(!|)(\/|)(\w*)(\ |)(\w*)([\\\=]*)(?|(\")\""\"|)(?|(.*)?"(\")|)([\ ]?)(\/|)>/i";$replacement = "<$1$2$3$4$5$6$7$8$9$10$11>";$text = preg_replace($tags, $replacement, $text);$text = preg_replace("/=\"\"/", "=", $text);$text = preg_replace("/"\"/", "\"", $text);retu...

php删除字符串HTML标签的函数示例

//删除字符串中html标签//by bbs.it-home.orgfunction delete_htm($scr) { for($i=0;$i{ if(substr($scr,$i,1)=="{ while(substr($scr,$i,1)!=">")$i++; $i++; } $str=$str.substr($scr,$i,1); } return($str); } ?>PHP如何去除HTML标签 方法1: 直接取出想要取出的标记 //取出br标记 function strip($str){$str=str_replace("<br>","",$str);//$str=htmlspecialchars($str);return strip_tags($str);}?>方法2. PHP 中有个 s...

PHP实现压缩html的函数

function compress_html($string) { $string = str_replace("\r\n", , $string); //清除换行符 $string = str_replace("\n", , $string); //清除换行符 $string = str_replace("\t", , $string); //清除制表符 $pattern = array ( "/> *([^ ]*) *</", //去掉注释标记 "/[\s]+/", "//", "/\" /", "/ \"/", ...

php发送邮件函数,支持html和普通文本

function send_mail($emailaddress, $fromaddress, $namefrom, $emailsubject, $body){ $eol="\n"; $mime_boundary=md5(time()); # Common Headers $headers .= "From: $namefrom ".$eol; $headers .= "Reply-To: $namefrom ".$eol; $headers .= "Return-Path: $namefrom ".$eol; // these two to set reply address $headers .= "Message-ID: ".$eol; $headers .= "X-Mailer: PHP v".phpversion().$eol; ...

可以获取任意Web页面HTML代码的PHP函数

function display_sourcecode($url){$lines = file($url);$output = "";foreach ($lines as $line_num => $line) { // loop thru each line and prepend line numbers $output.= "Line #{$line_num} : " . htmlspecialchars($line) . "\n";}}用法: $url = "http://www.open-open.com";$source = display_sourcecode($url);echo $source;?> Web, HTML, PHP