<?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>Erick &#187; 删除空行</title>
	<atom:link href="http://blog.xiongchuan.org/tag/delete-blank-lines/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.xiongchuan.org</link>
	<description>Even a great life is only a life until you make it.</description>
	<lastBuildDate>Thu, 10 Mar 2011 14:44:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type='text/javascript' src='http://blog.xiongchuan.org/wp-includes/js/jquery/jquery.js?ver=1.4.4'></script>
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
	<item>
		<title>终于下了决心，把博客从国内移到国外了</title>
		<link>http://blog.xiongchuan.org/blog-move-to-us.html</link>
		<comments>http://blog.xiongchuan.org/blog-move-to-us.html#comments</comments>
		<pubDate>Sun, 16 Jan 2011 04:49:38 +0000</pubDate>
		<dc:creator>Erick</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[删除空行]]></category>
		<category><![CDATA[迁移]]></category>

		<guid isPermaLink="false">http://www.pigblog.net/?p=672</guid>
		<description><![CDATA[再一次使用了sudu的在线压缩文件，打包下载快一点儿，又忘了上回的教训，直接上传到bluehost的空间， 可想而知，头部有输出，这回连后台都进不了。 用sudu的文件打包在所有文件末尾都加了一个空行，导致php包含的时候，就有空白输出了。 还好，哥为了解决这个问题，之前写过一段代码，现在又有用了。 删除所有文件的末行的空白。 如果有想要下载的哥，请稳步到 PHP批量删除空行&#124;wordpress迁移的艰辛 Related PostsPHP批量删除空行&#124;wordpress迁移的艰辛]]></description>
			<content:encoded><![CDATA[<p>再一次使用了sudu的在线压缩文件，打包下载快一点儿，又忘了上回的教训，直接上传到bluehost的空间，<br />
可想而知，头部有输出，这回连后台都进不了。</p>
<blockquote><p>用sudu的文件打包在所有文件末尾都加了一个空行，导致php包含的时候，就有空白输出了。</p></blockquote>
<p>还好，哥为了解决这个问题，之前写过一段代码，现在又有用了。<br />
删除所有文件的末行的空白。</p>
<p>如果有想要下载的哥，请稳步到 <a href="http://www.pigblog.net/batch-delete-blank-lines.html" rel="external nofollow">PHP批量删除空行|wordpress迁移的艰辛</a></p>
<h4  class="entry-title">Related Posts</h4><ul class="related_post"><li><a href="http://blog.xiongchuan.org/batch-delete-blank-lines.html" title="PHP批量删除空行|wordpress迁移的艰辛">PHP批量删除空行|wordpress迁移的艰辛</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.xiongchuan.org/blog-move-to-us.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP批量删除空行&#124;wordpress迁移的艰辛</title>
		<link>http://blog.xiongchuan.org/batch-delete-blank-lines.html</link>
		<comments>http://blog.xiongchuan.org/batch-delete-blank-lines.html#comments</comments>
		<pubDate>Thu, 24 Dec 2009 08:48:03 +0000</pubDate>
		<dc:creator>Erick</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[删除空行]]></category>

		<guid isPermaLink="false">http://www.pigblog.net/?p=501</guid>
		<description><![CDATA[博客这些天一直处于死亡状态，昨天空间商帮忙把博客从浙江机房搬到河南机房了，暂时可以开通了。 Warning: Cannot modify header information &#8211; headers already sent by (output started at /*****/wp-includes/compat.php:230 头部有输出，昨天加班到比较晚，回家看《花木兰》，没去管博客，今天来公司，发现问题严重了，Google竟然抓取了页面 打开这些PHP的文件，发现下面全部都多了两行，就是php闭合标签之后多出了两个空行，造成在include 或是 require 后会有输出。 开始以为是只有几个文件是这样的，多打开几个发现，整个空间里面的php文件js,css,php都多出了两个空行，估计是华夏名网的在线文件管理器打包造成的。 因为本人对正则不熟悉，不过其实用正则替换倒不是太难，关键问题在于windows和linux下面的换行，回车符号的区别，费了不少时间研究。 虽然我知道windows下面是\r\n linux下面是\n 可是我用\r\n在windows系统上怎么也匹配不了，后来才发现我用的eclipse里面的我用的是Unix格式，换行就是\n，而不是\r\n，功夫不负苦心人哈，把代码贴出，也可以下载，有什么更好的方法，记得告诉我哈，各位！ //$path=__DIR__;//php 5.3 $path=dirname(__FILE__); function get_all_files($path,$pattern='/php$&#124;js$&#124;css$/i'){ $list = array(); foreach( glob( $path.DIRECTORY_SEPARATOR.'*') as $item ){ if( is_dir( $item ) ){ $list = array_merge( $list , get_all_files( $item,$pattern ) ); } else{ [...]]]></description>
			<content:encoded><![CDATA[<p>博客这些天一直处于死亡状态，昨天空间商帮忙把博客从浙江机房搬到河南机房了，暂时可以开通了。<br />
Warning: Cannot modify header information &#8211; headers already sent by (output started at /*****/wp-includes/compat.php:230<br />
头部有输出，昨天加班到比较晚，回家看《花木兰》，没去管博客，今天来公司，发现问题严重了，Google竟然抓取了页面<br />
<a href="http://www.pigblog.net/photos/photo/4210018847/pigblog.html" class="tt-flickr tt-flickr-Large" title="pigblog" rel="external nofollow"><img class="aligncenter" src="http://farm3.static.flickr.com/2556/4210018847_840f17f0ff_o.jpg" alt="pigblog" width="503" height="112" /></a><br />
打开这些PHP的文件，发现下面全部都多了两行，就是php闭合标签之后多出了两个空行，造成在include 或是 require 后会有输出。<br />
开始以为是只有几个文件是这样的，多打开几个发现，整个空间里面的php文件js,css,php都多出了两个空行，估计是华夏名网的在线文件管理器打包造成的。<br />
因为本人对正则不熟悉，不过其实用正则替换倒不是太难，关键问题在于windows和linux下面的换行，回车符号的区别，费了不少时间研究。<br />
虽然我知道windows下面是\r\n linux下面是\n  可是我用\r\n在windows系统上怎么也匹配不了，后来才发现我用的eclipse里面的我用的是Unix格式，换行就是\n，而不是\r\n，功夫不负苦心人哈，把代码贴出，也可以下载，有什么更好的方法，记得告诉我哈，各位！</p>
<pre name="code" class="php">
//$path=__DIR__;//php 5.3
$path=dirname(__FILE__);
function get_all_files($path,$pattern='/php$|js$|css$/i'){
    $list = array();
    foreach( glob( $path.DIRECTORY_SEPARATOR.'*') as $item ){
        if( is_dir( $item ) ){
         $list = array_merge( $list , get_all_files( $item,$pattern ) );
        }
        else{
            if(preg_match($pattern,$item)){
                $list[] = $item;
        	}
        }
    }
    return $list;
}
$list=get_all_files($path,'/php$/i');
foreach($list as $v){
$str=file_get_contents($v);
//var_dump($str);
$str=preg_replace("/\?>\s*$/i",'?>',$str);
//var_dump($str);
file_put_contents($v,$str);
}
header('Content-Type:text/html;Charset=utf-8');
echo "删除空白完成，Have a good time!";
echo "<a href="/index.php" >回首页</a>";
</pre>
<p><a href="http://www.pigblog.net/removespace.rar" rel="external nofollow">点这里下载文件</a><br />
解压后放到空间的根目录下面，会遍历所有子目录，并删除末尾的空行。</p>
<h4  class="entry-title">Related Posts</h4><ul class="related_post"><li><a href="http://blog.xiongchuan.org/blog-move-to-us.html" title="终于下了决心，把博客从国内移到国外了">终于下了决心，把博客从国内移到国外了</a></li><li><a href="http://blog.xiongchuan.org/blog-back.html" title="博客归来，更简洁了">博客归来，更简洁了</a></li><li><a href="http://blog.xiongchuan.org/flickr-photo-album-for-wordpress.html" title="Flickr Photo Album for WordPress|wp 相册">Flickr Photo Album for WordPress|wp 相册</a></li><li><a href="http://blog.xiongchuan.org/centos-5-3-apache2-mysql5-php-5-3-server.html" title="CentOS 5.3搭建Apache2.2.4+Mysql5.1.4+PHP5.3服务器">CentOS 5.3搭建Apache2.2.4+Mysql5.1.4+PHP5.3服务器</a></li><li><a href="http://blog.xiongchuan.org/warning-strtotime-function-strtotime-it-is-not-safe-to-rely-on-the-system-timezone-settings-resolve.html" title="Warning: strtotime() [function.strtotime]: It is not safe to rely on the system’s timezone settings. 解决方法">Warning: strtotime() [function.strtotime]: It is not safe to rely on the system’s timezone settings. 解决方法</a></li><li><a href="http://blog.xiongchuan.org/add-author-name-for-wordpress.html" title="给博客加个作者|wordpress作者函数">给博客加个作者|wordpress作者函数</a></li><li><a href="http://blog.xiongchuan.org/change-blog-program-to-wordpress.html" title="换博客啦">换博客啦</a></li><li><a href="http://blog.xiongchuan.org/php-braces-description.html" title="PHP的大括号，详解">PHP的大括号，详解</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.xiongchuan.org/batch-delete-blank-lines.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

