<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[file_get_contents的urlencode的问题。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[生活笔记]]></category>
<pubDate>Mon, 14 Jul 2008 06:21:39 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	在编写php程序的时候，往往会出现对其post get 等的编码,于是就有对空格的处理，程序如下：<br/>&lt;?php<br/>$file=file(&quot;D:&#92;wwwroot&#92;www&#92;htdocs&#92;sinanet.txt&quot;);<br/>//$file=file(&quot;D:&#92;wwwroot&#92;www&#92;htdocs&#92;sinatest.txt&quot;);<br/>$count=0;<br/>$line=0;<br/>for($i=0;$i&lt;=count($file);$i++)<br/>{<br/>&nbsp;&nbsp;$line=$line+1;<br/>&nbsp;&nbsp;echo $line.&quot;&#92;n&quot;;<br/>&nbsp;&nbsp;$result = explode(&quot;sinanet&quot;,$file[$i]);<br/>&nbsp;&nbsp;&nbsp;&nbsp;for($j=0;$j&lt;count($result);$j++)<br/>&nbsp;&nbsp;{<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;if($result[$j])<br/>&nbsp;&nbsp;&nbsp;&nbsp;{<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$url=&quot;http://you.video.sina.com.cn/pg/search/iaskSearch.class.php?key=&#92;&quot;&quot;.urlencode($result[$j]).&quot;&#92;&quot;&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$judge=file_get_contents($url);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$judge_handle = strstr($judge,&quot;抱歉&quot;);//专辑推荐<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if($judge_handle)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;$count=$count+1;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$rest = substr($judge_handle, 0, 14);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $rest;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;关键词:&quot;.$result[$j].&quot;&#92;n&quot;;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}else{<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $url;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;&#92;n关键词:&quot;.$result[$j].&quot;可能没有出现抱歉***！&quot;.&quot;&#92;n&quot;;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;}else{<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo &quot;有问题：&quot;.$result[$j].&quot;&#92;n&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br/><br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;echo &quot;&#92;n&quot;;<br/><br/><br/>}<br/>echo &quot;总共找到抱歉条目:&quot;.$count.&quot;分析文件&quot;.$line.&quot;行！&quot;;<br/>?&gt;&nbsp;&nbsp;<br/><br/>以上语句如果不用urlencode()来进行编码，往往容易出现问题,example:<br/><br/>&lt;?php<br/>$key = &quot;Chinese Democracy&quot;;<br/>$key = urlencode($key);<br/>$url = &quot;http://you.video.sina.com.cn/pg/search/iaskSearch.class.php?key=&quot;.$key;<br/>$judge= file_get_contents($url);<br/>echo $judge;<br/>return;<br/>$judge_handle = strstr($judge,&quot;抱歉&quot;);//专辑推荐<br/><br/>if($judge_handle)<br/>{&nbsp;&nbsp;<br/>&nbsp;&nbsp;$count=$count+1;<br/>&nbsp;&nbsp;$rest = substr($judge_handle, 0, 14);<br/>&nbsp;&nbsp;echo $rest;<br/>&nbsp;&nbsp;echo &quot;关键词:&quot;.$result[$j].&quot;&#92;n&quot;;<br/>}else{<br/>&nbsp;&nbsp;echo $url;<br/>&nbsp;&nbsp;echo &quot;&lt;br&gt;关键词:&quot;.$result[$j].&quot;可能没有出现抱歉***！&quot;.&quot;&#92;n&quot;;<br/>&nbsp;&nbsp;&nbsp;&nbsp; }<br/>?&gt;<br/>不加上urlencode会出现如下问题：$url = &quot;http://you.video.sina.com.cn/pg/search/iaskSearch.class.php?key=’Chinese‘ 而不是：&quot;Chinese Democracy&quot;,为此最好每次涉及到url的时候加上urlencode.
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] file_get_contents的urlencode的问题。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>