【纯CSS3悬停图标旋转导航动画代码_html/css_WEB-ITnose】教程文章相关的互联网学习教程文章

php压缩html网页代码(清除空格、换行符、制表符、注释标记等)的方法

/*** 压缩html : 清除换行符,清除制表符,去掉注释标记* @param $string* @return 压缩后的$string* from: bbs.it-home.org* */function compress_html($string) {$string = str_replace("\r\n", '', $string); //清除换行符$string = str_replace("\n", '', $string); //清除换行符$string = str_replace("\t", '', $string); //清除制表符$pattern = array ("/> *([^ ]*) *"/[\s]+/","//","/\" /","/ \"/","'/\*[^*]*\*/'");$repl...

将数据库中的所有内容生成html静态页面的代码

require_once("conn.php");if($_GET['all']){/*获取数据库记录,以便于生成html文件有个文件名*/$sqlquery = "select * from $tbname";$result = mysql_query($sqlquery,$conn)or die("查询失败!");$fp = fopen("./template/article.html",r);$fpcontent = fread($fp,filesize("./template/article.html"));fclose($fp);/*写入文件*/while($row = mysql_fetch_array($result)){$fpcontent = str_replace("{thetitle}",$row['title'...

修复未正常关闭的HTML标签(支持嵌套和就近闭合)的代码【图】

/** * fixHtmlTag * * html标签修复函数,此函数可以修复未正确闭合的 HTML 标签 * * 由于不确定性因素太多,暂时提供两种模式“嵌套闭合模式”和 * “就近闭合模式”,应该够用了。 * * 这两种模式是我为了解释清楚此函数的实现而创造的两个名词, * 只需明白什么意思就行。 * 1,嵌套闭合模式,NEST,为默认的闭合方式。即 "你好" * 这样的 html 代码会被修改为 "你好" * 2,就近闭合模式,CLOSE,这种模式会将形如 "你好为什么没...

php正则过滤html标签、空格、换行符等的代码示例

/** desc:正则过滤html标签、空格、换行符等 link:bbs.it-home.org date:2013/2/23*/$str=preg_replace("/\s+/", " ", $str); //过滤多余回车$str=preg_replace("/$str=preg_replace("//si","",$str); //注释$str=preg_replace("//si","",$str); //过滤DOCTYPE$str=preg_replace("//si","",$str); //过滤html标签$str=preg_replace("//si","",$str); //过滤head标签$str=preg_replace("//si","",$str); //过滤meta标签$str=p...

文本转HTML的php代码

<php//文本转HTMLfunction Text2Html($txt){$txt = str_replace(” ”,” ”,$txt);$txt = str_replace(“<”,”<”,$txt);$txt = str_replace(“>”,”>”,$txt);$txt = preg_replace(“/[\r\n]{1,}/isU”,”\r\n”,$txt);return $txt;}?>

去除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...

phpcleanhtml代码(设置过滤及保留属性)【图】

php实现的可以设置过滤及保留相关属性的代码,有需要的朋友可以参考下。代码如下:"\^", "[" => "\[", "." => "\.", "$" => "\$", "{" => "\{", "*" => "\*", "(" => "\(", "\\" => "\\\\", "/" => "\/", "+" => "\+", ")" => "\)", "|" => "\|", "?" => "\?", " "\" => "\>" ); return strtr( $str, $conversions ); } class cleanHtml{ public $str = ''; public $allow = array(); public $exceptions = ...

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读写文件生成HTML的代码举例

//生成HTML$countfile="template.html";$num=file_get_contents($countfile);echo $num;$num=str_replace("|*|*|PAGE_TITLE|*|*|","myhome",$num);$path="template.html";$handle=fopen($path,"w"); //写入方式打开新闻路径fwrite($handle,$num); //把刚才替换的内容写进生成的HTML文件fclose($handle);?>说明: file_get_contents -- 将整个文件读入一个字符串 file -- 把整个文件读入一个数组中 详细参考: php file_get_content...

php删除html标签及字符串中html标签的代码

本文介绍下,php实现删除html标签,以及字符串中html标签的两例代码,有需要的朋友,参考下吧。1,删除html标签的例子 用到了php字符串处理函数strip_tags。"); //利用php自带的函数清除html格式。保留P标签 $str = preg_replace("/\t/","",$str); //使用正 则 表 达 式匹配需要替换的内容,如:空格,换行,并将替换为空。 $str = preg_replace("/\r\n/","",$str); $str = preg_replace("/\r/","",$str); $str = preg_replace("/\...

php定时生成静态html的代码分享

本文介绍下,用php定时生成静态html首页的一例代码,有需要的朋友参考下。用php定时生成静态页面。 代码如下:start(); //打开缓冲区 include(”index.php”); $content = ob_get_contents(); //得到缓冲区的内容 $content .= “n”; //加上调用更新程序的代码file_put_contents(”index.html”,$content);if (!function_exists(”file_put_contents”)) {function file_put_contents($fn,$fs){$fp=fopen($fn,”w+”);fputs($fp,$f...

php实现gzip压缩html数据的代码

本文介绍下,用php实现gzip方法压缩html页面的一例代码,有需要的朋友参考下。代码如下:有兴趣的朋友,可以百度下检测gzip压缩效果的工具或网站,看看压缩比率如何!

提取html标签的php代码示例

提取html标签的php代码示例 <?php /** * 函数: tags * 功能: 从文件中提取html标签 * * 入口: * $filename 文件名 * $tag 标签名 * 返回: * 数组,每项为: * tagName String * Text String * Attrs Array * * 示例: * print_r(tags("test1.htm","a")); * print_r("http://localhost/index.htm","img"); * */</p> <p>function tags($filename,$tag) { $buffer = join("",file($filename)); $buffer = eregi_replace("\r\n","",$buffe...

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]+/", ...