<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>替换 &#8211; LPC影子技术分享</title>
	<atom:link href="https://www.mudbest.com/tag/%E6%9B%BF%E6%8D%A2/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.mudbest.com</link>
	<description>行影不离,忘之却步.</description>
	<lastBuildDate>Tue, 27 Nov 2012 08:39:09 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.1</generator>
	<item>
		<title>PHP对html进行压缩</title>
		<link>https://www.mudbest.com/php%e5%af%b9html%e8%bf%9b%e8%a1%8c%e5%8e%8b%e7%bc%a9/</link>
		
		<dc:creator><![CDATA[hkshadow]]></dc:creator>
		<pubDate>Tue, 27 Nov 2012 08:39:09 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[preg_replace]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[压缩]]></category>
		<category><![CDATA[替换]]></category>
		<guid isPermaLink="false">http://www.mudbest.com/?p=1716</guid>

					<description><![CDATA[原理：清除换行符,清除制表符,去掉注释标记 。 说白了就是替换多余的字符，以达到html页面的压缩。 代码：]]></description>
										<content:encoded><![CDATA[<p>原理：清除换行符,清除制表符,去掉注释标记 。<br />
说白了就是替换多余的字符，以达到html页面的压缩。<br />
<span id="more-1716"></span><br />
代码：</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/**
* 压缩html : 清除换行符,清除制表符,去掉注释标记
* @param $string
* @return 压缩后的$string
* */
function compress_html($string) {
	$string = str_replace ( &quot;\r\n&quot;, '', $string ); // 清除换行符
	$string = str_replace ( &quot;\n&quot;, '', $string ); // 清除换行符
	$string = str_replace ( &quot;\t&quot;, '', $string ); // 清除制表符
	$pattern = array (&quot;/&gt; *(&#x5B;^ ]*) *&lt;/&quot;, 	// 去掉注释标记
	&quot;/&#x5B;\s]+/&quot;, &quot;/&lt;!--&#x5B;^!]*--&gt;/&quot;, &quot;/\&quot; /&quot;, &quot;/ \&quot;/&quot;, &quot;'/\*&#x5B;^*]*\*/'&quot; );
	$replace = array (&quot;&gt;\\1&lt;&quot;, &quot; &quot;, &quot;&quot;, &quot;\&quot;&quot;, &quot;\&quot;&quot;, &quot;&quot; );
	return preg_replace ( $pattern, $replace, $string );
}
?&gt; 
</pre>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
