<?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>天生我才必有用 &#187; PHP</title>
	<atom:link href="http://ray.imiddle.net/category/tech/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://ray.imiddle.net</link>
	<description>狂人的成长史</description>
	<lastBuildDate>Thu, 17 Nov 2011 01:01:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Drupal 文件系统</title>
		<link>http://ray.imiddle.net/2011/08/drupal-file-system/</link>
		<comments>http://ray.imiddle.net/2011/08/drupal-file-system/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 01:17:50 +0000</pubDate>
		<dc:creator>Ray</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Drupal7]]></category>

		<guid isPermaLink="false">http://ray.imiddle.net/?p=725</guid>
		<description><![CDATA[Drupal7 的文件系统使用了3种自定义的URI，操作起来和访问http、ftp协议类似，比较直观。 public:// private:// temp:// 用户还可以自己定义stream wrapper，来实现自己的URI。具体内容参见：DrupalStreamWrapperInterface。 当调用file_save_data时，有三种模式可以选择： FILE_EXISTS_REPLACE：覆盖原有的文件 FILE_EXISTS_RENAME：对文件名从新命名，自动添加_1,_2等后缀。 FILE_EXISTS_ERROR：什么事情都不做，直接返回错误。 默认为FILE_EXISTS_RENAME模式。 如果保存成功则返回drupal的file对象。]]></description>
			<content:encoded><![CDATA[<p>Drupal7 的文件系统使用了3种自定义的URI，操作起来和访问http、ftp协议类似，比较直观。</p>
<ul>
<li>public://</li>
<li>private://</li>
<li>temp://</li>
</ul>
<p>用户还可以自己定义stream wrapper，来实现自己的URI。具体内容参见：DrupalStreamWrapperInterface。</p>
<p>当调用file_save_data时，有三种模式可以选择：</p>
<ul>
<li>FILE_EXISTS_REPLACE：覆盖原有的文件</li>
<li>FILE_EXISTS_RENAME：对文件名从新命名，自动添加_1,_2等后缀。</li>
<li>FILE_EXISTS_ERROR：什么事情都不做，直接返回错误。</li>
</ul>
<p>默认为FILE_EXISTS_RENAME模式。</p>
<p>如果保存成功则返回drupal的file对象。</p>
]]></content:encoded>
			<wfw:commentRss>http://ray.imiddle.net/2011/08/drupal-file-system/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal Test Part 1</title>
		<link>http://ray.imiddle.net/2011/08/drupal-test-part-1/</link>
		<comments>http://ray.imiddle.net/2011/08/drupal-test-part-1/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 01:09:16 +0000</pubDate>
		<dc:creator>Ray</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Drupal7]]></category>

		<guid isPermaLink="false">http://ray.imiddle.net/?p=717</guid>
		<description><![CDATA[最新的Drupal7提供了单元测试的功能，为你的代码健壮性提供了保证。 建立一个module.test的文件作为你模块的测试文件，module请替换成你的模块名称。 建立一个继承DrupalWebTestCase的类，并实现其中的getInfo的函数。 添加一个setUp的函数，这个函数类似所有单元测试中的setup函数，不过在这个函数中必须加入parent::setup(&#8216;module&#8217;)，其中module是你的模块名称。 在后台的激活testing模块。 在admin/config/development/testing/设定页面中，点击“Clean Environment”按钮，就可以在列表中看到你的测试模块了。]]></description>
			<content:encoded><![CDATA[<p>最新的Drupal7提供了单元测试的功能，为你的代码健壮性提供了保证。</p>
<ol>
<li>建立一个module.test的文件作为你模块的测试文件，module请替换成你的模块名称。</li>
<li>建立一个继承DrupalWebTestCase的类，并实现其中的getInfo的函数。</li>
<li>添加一个setUp的函数，这个函数类似所有单元测试中的setup函数，不过在这个函数中必须加入parent::setup(&#8216;module&#8217;)，其中module是你的模块名称。</li>
<li>在后台的激活testing模块。</li>
<li>在admin/config/development/testing/设定页面中，点击“Clean Environment”按钮，就可以在列表中看到你的测试模块了。</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://ray.imiddle.net/2011/08/drupal-test-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento定制主菜单</title>
		<link>http://ray.imiddle.net/2011/03/magento%e5%ae%9a%e5%88%b6%e4%b8%bb%e8%8f%9c%e5%8d%95/</link>
		<comments>http://ray.imiddle.net/2011/03/magento%e5%ae%9a%e5%88%b6%e4%b8%bb%e8%8f%9c%e5%8d%95/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 03:45:46 +0000</pubDate>
		<dc:creator>Ray</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://ray.imiddle.net/?p=683</guid>
		<description><![CDATA[此篇文章讲述了如何定制您的Magento Store的菜单 http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/navigation/add_home_link_to_menu_bar 使用CSS隐藏主菜单项 http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/catalog/hide_navigation_item_s_with_css]]></description>
			<content:encoded><![CDATA[<ul>
<li>此篇文章讲述了如何定制您的Magento Store的菜单</li>
</ul>
<p style="padding-left: 30px;"><a href="http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/navigation/add_home_link_to_menu_bar" target="_blank">http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/navigation/add_home_link_to_menu_bar</a></p>
<ul>
<li>使用CSS隐藏主菜单项</li>
</ul>
<p style="padding-left: 30px;"><a href="http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/catalog/hide_navigation_item_s_with_css" target="_blank">http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/catalog/hide_navigation_item_s_with_css</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ray.imiddle.net/2011/03/magento%e5%ae%9a%e5%88%b6%e4%b8%bb%e8%8f%9c%e5%8d%95/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento转换URL</title>
		<link>http://ray.imiddle.net/2011/03/magento-url-functions/</link>
		<comments>http://ray.imiddle.net/2011/03/magento-url-functions/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 04:24:19 +0000</pubDate>
		<dc:creator>Ray</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://ray.imiddle.net/?p=681</guid>
		<description><![CDATA[Get the base url 1 2 3 4 5 Mage::getBaseUrl&#40;Mage_Core_Model_Store::URL_TYPE_WEB&#41;; Mage::getBaseUrl&#40;Mage_Core_Model_Store::URL_TYPE_LINK&#41;; // default Mage::getBaseUrl&#40;Mage_Core_Model_Store::URL_TYPE_SKIN&#41;; Mage::getBaseUrl&#40;Mage_Core_Model_Store::URL_TYPE_MEDIA&#41;; Mage::getBaseUrl&#40;Mage_Core_Model_Store::URL_TYPE_JS&#41;; Get the skin url 1 $this-&#62;getSkinUrl&#40;&#41;;]]></description>
			<content:encoded><![CDATA[<h4>Get the base url</h4>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">Mage<span style="color: #339933;">::</span><span style="color: #004000;">getBaseUrl</span><span style="color: #009900;">&#40;</span>Mage_Core_Model_Store<span style="color: #339933;">::</span><span style="color: #004000;">URL_TYPE_WEB</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Mage<span style="color: #339933;">::</span><span style="color: #004000;">getBaseUrl</span><span style="color: #009900;">&#40;</span>Mage_Core_Model_Store<span style="color: #339933;">::</span><span style="color: #004000;">URL_TYPE_LINK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// default</span>
Mage<span style="color: #339933;">::</span><span style="color: #004000;">getBaseUrl</span><span style="color: #009900;">&#40;</span>Mage_Core_Model_Store<span style="color: #339933;">::</span><span style="color: #004000;">URL_TYPE_SKIN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Mage<span style="color: #339933;">::</span><span style="color: #004000;">getBaseUrl</span><span style="color: #009900;">&#40;</span>Mage_Core_Model_Store<span style="color: #339933;">::</span><span style="color: #004000;">URL_TYPE_MEDIA</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Mage<span style="color: #339933;">::</span><span style="color: #004000;">getBaseUrl</span><span style="color: #009900;">&#40;</span>Mage_Core_Model_Store<span style="color: #339933;">::</span><span style="color: #004000;">URL_TYPE_JS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h4>Get the skin url</h4>
<div><code> </code></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getSkinUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

</div>
<div></div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://ray.imiddle.net/2011/03/magento-url-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magento定制Sidebar</title>
		<link>http://ray.imiddle.net/2011/03/magento-customize-sidebar/</link>
		<comments>http://ray.imiddle.net/2011/03/magento-customize-sidebar/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 09:44:16 +0000</pubDate>
		<dc:creator>Ray</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[Magento]]></category>

		<guid isPermaLink="false">http://ray.imiddle.net/?p=673</guid>
		<description><![CDATA[删除Paypal Partner &#60;remove name=”paypal.partner.right.logo” /&#62;  &#60;!&#8211;paypal logo&#8211;&#62; 删除Community Poll &#60;remove name=”right.poll”/&#62; &#60;remove name=”left.poll”/&#62; 删除Tags &#60;remove name=”tags_popular”/&#62; 删除Compare Products &#60;remove name=”catalog.compare.sidebar” /&#62;  &#60;!&#8211;product compare&#8211;&#62; 删除Reorder &#60;remove name=”sale.reorder.sidebar”/&#62; 删除WishList &#60;remove name=”wishlist_sidebar”/&#62; 删除Dog &#60;remove name=”left.permanent.callout” /&#62;  &#60;!&#8211;the dog&#8211;&#62; 删除Back to School &#60;remove name=”right.permanent.callout” /&#62;  &#60;!&#8211;back to school&#8211;&#62; 删除购物车 &#60;remove name=”cart_sidebar” /&#62; &#60;!&#8211;cart sidebar&#8211;&#62; 删除recently viewed product &#60;remove name=”left.reports.product.viewed” [...]]]></description>
			<content:encoded><![CDATA[<p><strong>删除Paypal Partner </strong></p>
<p>&lt;remove name=”paypal.partner.right.logo” /&gt;  &lt;!&#8211;paypal logo&#8211;&gt;</p>
<p><strong>删除Community Poll</strong></p>
<p>&lt;remove name=”right.poll”/&gt;<br />
&lt;remove name=”left.poll”/&gt;</p>
<p><strong>删除Tags</strong></p>
<p>&lt;remove name=”tags_popular”/&gt;</p>
<p><strong>删除</strong><strong>Compare Products </strong></p>
<p>&lt;remove name=”catalog.compare.sidebar” /&gt;  &lt;!&#8211;product compare&#8211;&gt; <strong> </strong></p>
<p><strong>删除Reorder</strong></p>
<p>&lt;remove name=”sale.reorder.sidebar”/&gt;</p>
<p><strong>删除WishList</strong></p>
<p><strong></strong>&lt;remove name=”wishlist_sidebar”/&gt;</p>
<p><strong>删除Dog</strong></p>
<p>&lt;remove name=”left.permanent.callout” /&gt;  &lt;!&#8211;the dog&#8211;&gt;</p>
<p><strong>删除Back to School</strong></p>
<p>&lt;remove name=”right.permanent.callout” /&gt;  &lt;!&#8211;back to school&#8211;&gt;</p>
<p><strong>删除购物车</strong></p>
<p>&lt;remove name=”cart_sidebar” /&gt; &lt;!&#8211;cart sidebar&#8211;&gt;</p>
<p><strong>删除recently viewed product</strong></p>
<p>&lt;remove name=”left.reports.product.viewed” /&gt; &lt;!&#8211;recently viewed prod&#8211;&gt;<br />
&lt;remove name=”right.reports.product.viewed” /&gt; &lt;!&#8211;recently viewed prod&#8211;&gt;</p>
<p><strong>删除recently compared product</strong></p>
<p><strong></strong>&lt;remove name=”right.reports.product.compared” /&gt; &lt;!&#8211;recently compared prod&#8211;&gt;</p>
<p>更多信息请参考<a href="http://www.magentocommerce.com/knowledge-base/entry/turning-on-off-magentos-content-blocks/" target="_blank">Turning On and Off Magento&#8217;s Default Blocks</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ray.imiddle.net/2011/03/magento-customize-sidebar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal 测试邮件发送</title>
		<link>http://ray.imiddle.net/2011/03/drupal-debug-email-problems/</link>
		<comments>http://ray.imiddle.net/2011/03/drupal-debug-email-problems/#comments</comments>
		<pubDate>Thu, 03 Mar 2011 07:57:24 +0000</pubDate>
		<dc:creator>Ray</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[drupal]]></category>

		<guid isPermaLink="false">http://ray.imiddle.net/?p=669</guid>
		<description><![CDATA[Reroute Email模块可以帮助你进行邮件发送的测试。 This module intercepts all outgoing emails from a Drupal site and reroutes them to a predefined configurable email address. This is useful in case where you do not want email sent from a Drupal site to reach the users. For example, if you copy a live site to a test site for the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://drupal.org/project/reroute_email" target="_blank">Reroute Email</a>模块可以帮助你进行邮件发送的测试。</p>
<p>This module intercepts all outgoing emails from a Drupal site and reroutes them to a predefined configurable email address.</p>
<p>This is useful in case where you do not want email sent from a Drupal  site to reach the users. For example, if you copy a live site to a test  site for the purpose of development, and you do not want any email sent  to real users of the original site. Or you want to check the emails  sent for uniform formatting, footers, &#8230;etc.</p>
<p>This is also a good demonstration of what <a rel="nofollow" href="http://api.drupal.org/api/5/function/hook_mail_alter">hook_mail_alter()</a>, available in Drupal 5.x and later, can do.</p>
]]></content:encoded>
			<wfw:commentRss>http://ray.imiddle.net/2011/03/drupal-debug-email-problems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal 7常用theme hooks</title>
		<link>http://ray.imiddle.net/2011/03/drupal7-common-theme-hooks/</link>
		<comments>http://ray.imiddle.net/2011/03/drupal7-common-theme-hooks/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 01:45:39 +0000</pubDate>
		<dc:creator>Ray</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[Drupal7]]></category>

		<guid isPermaLink="false">http://ray.imiddle.net/?p=657</guid>
		<description><![CDATA[file_link Returns HTML for a link to a file. html_tag Returns HTML for a generic HTML tag with attributes. This can often be too generic a theme hook to use, but is really useful for adding a tag to the of a document or for theming a tag inside a render element. image Returns HTML [...]]]></description>
			<content:encoded><![CDATA[<p><strong>file_link</strong><br />
Returns HTML for a link to a file.</p>
<p><strong>html_tag</strong><br />
Returns HTML for a generic HTML tag with attributes. This can often be too generic a theme hook to use, but is really useful for adding a tag to the  of a document or for theming a tag inside a render element.</p>
<p><strong>image </strong><br />
Returns HTML for an image. image_style Returns HTML for an image using a specific image style.</p>
<p><strong>item_list</strong><br />
Returns HTML for a list of items which can optionally be nested.</p>
<p><strong>links </strong><br />
Returns HTML for a list of links (cannot be nested).</p>
<p><strong>more_link </strong><br />
Returns HTML for a more link, often used on blocks.</p>
<p><strong>pager </strong><br />
Returns HTML for a pager query element, a list of pages for result sets too long for one page.</p>
<p><strong>progress_bar</strong><br />
Returns HTML for an indicator showing a task&#8217;s progress.</p>
<p><strong>table </strong><br />
Returns HTML for a table.</p>
<p><strong>username </strong><br />
Returns HTML for a username.</p>
<p><strong>user_list</strong><br />
Returns HTML for a list of users.</p>
<p><strong>user_picture</strong><br />
Returns HTML for a picture configured for the user&#8217;s account.</p>
]]></content:encoded>
			<wfw:commentRss>http://ray.imiddle.net/2011/03/drupal7-common-theme-hooks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal t函数</title>
		<link>http://ray.imiddle.net/2011/02/drupal-t-function/</link>
		<comments>http://ray.imiddle.net/2011/02/drupal-t-function/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 02:24:23 +0000</pubDate>
		<dc:creator>Ray</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[drupal]]></category>

		<guid isPermaLink="false">http://ray.imiddle.net/?p=648</guid>
		<description><![CDATA[Drupal supports translation is largely through the t() function. The function takes an optional second argument。 1 2 $values = array&#40;'@user' =&#62; $username&#41;; print t&#40;'Welcome, @user', $values&#41;; If the placeholder begins with at sign @, then before it inserts the value, Drupal sanitizes the value using its internal check_plain() function. 1 2 $values = array&#40;'!url' [...]]]></description>
			<content:encoded><![CDATA[<p>Drupal supports translation is largely through the <strong>t()</strong> function.</p>
<p>The function takes an optional second argument。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$values</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'@user'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$username</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Welcome, @user'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$values</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>If the placeholder begins with at sign @, then before it inserts the value, Drupal sanitizes  the value using its internal check_plain() function.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$values</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'!url'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'The website can be found at !url'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$values</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>If the placeholder begins with exclamation mark !,  then it will be entered with no escaping. We can do this safely only because we already know the value of URL.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$values</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%color'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'blue'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'My favorite color is %color.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$values</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>If the placeholder begins with the percent sign %, it tells Drupal  to escape the code and to mark it as emphasized. (The content will be embedded in the <strong>em</strong> tag)</p>
]]></content:encoded>
			<wfw:commentRss>http://ray.imiddle.net/2011/02/drupal-t-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用PHP读取Excel文件</title>
		<link>http://ray.imiddle.net/2009/11/how-to-read-the-excel-with-php/</link>
		<comments>http://ray.imiddle.net/2009/11/how-to-read-the-excel-with-php/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 06:28:01 +0000</pubDate>
		<dc:creator>Ray</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[Excel]]></category>
		<category><![CDATA[OLE]]></category>

		<guid isPermaLink="false">http://ray.imiddle.net/?p=601</guid>
		<description><![CDATA[可能这应该算得上一个很古老的问题，解决的也有多种多样，不过Internet上比较多的是Excel的保存的范例，所以写一篇如何读取Excel，可能对大家有所帮助。 使用COM接口调用，把Excel应用程序作为一个Server，PHP间接使用Excel来读取文件。 使用PHPExcel的程序包。它的优点不单单读取资料而且可以保存资料为Excel文件，同时还支持Excel 2007的格式。方法就是把Excel看作一个普通的Excel文件读取。 还有一种是PHP Excel Reader，它把Excel文件看作一个二进制文件读取，不过不支持新版本Excel文件。 方法2可能看起来不错，不过当你在读取资料大比较大的文件时，会有一个致命的缺点：内存溢出。因为它必须把整个Excel读入内存。有点像XML的DOM接口，不清楚是否有类型XML的SAX的方法。 方法3有类似方法2内存溢出的问题，同时对新版的支持较差。 方法1应该是属于非常传统的方式，只有支持COM程序接口就可。同时只有你能用当前安装的Excel打开此文件，你就可以通过COM接口读取文件。缺点就是你必须在你的电脑上安装Excel。不过对于大文件现在只能使用这个方法。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 $doc = &#34;test.xls&#34; ; $excel_app = new COM&#40;&#34;Excel.Application&#34;, NULL, CP_UTF8&#41; or die &#40;&#34;Please install the Excel. \n&#34;&#41;; &#160; #$excel_app-&#62;Visible = 1; $workbook = [...]]]></description>
			<content:encoded><![CDATA[<p>可能这应该算得上一个很古老的问题，解决的也有多种多样，不过Internet上比较多的是Excel的保存的范例，所以写一篇如何读取Excel，可能对大家有所帮助。</p>
<ol>
<li>使用COM接口调用，把Excel应用程序作为一个Server，PHP间接使用Excel来读取文件。</li>
<li>使用<a href="http://www.phpexcel.net/" target="_blank">PHPExcel</a>的程序包。它的优点不单单读取资料而且可以保存资料为Excel文件，同时还支持Excel 2007的格式。方法就是把Excel看作一个普通的Excel文件读取。</li>
<li>还有一种是<a href="http://sourceforge.net/projects/phpexcelreader">PHP Excel Reader</a>，它把Excel文件看作一个二进制文件读取，不过不支持新版本Excel文件。</li>
</ol>
<p>方法2可能看起来不错，不过当你在读取资料大比较大的文件时，会有一个致命的缺点：内存溢出。因为它必须把整个Excel读入内存。有点像XML的DOM接口，不清楚是否有类型XML的SAX的方法。</p>
<p>方法3有类似方法2内存溢出的问题，同时对新版的支持较差。</p>
<p>方法1应该是属于非常传统的方式，只有支持COM程序接口就可。同时只有你能用当前安装的Excel打开此文件，你就可以通过COM接口读取文件。缺点就是你必须在你的电脑上安装Excel。不过对于大文件现在只能使用这个方法。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$doc</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;test.xls&quot;</span> <span style="color: #339933;">;</span>
<span style="color: #000088;">$excel_app</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> COM<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Excel.Application&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">,</span> CP_UTF8<span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Please install the Excel. <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#$excel_app-&gt;Visible = 1;
</span>
<span style="color: #000088;">$workbook</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$excel_app</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Workbooks</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Open</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$doc</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Can't open &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$doc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$worksheet</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$workbook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">WorkSheets</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$worksheet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">activate</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$min_row</span>    <span style="color: #339933;">=</span> <span style="color: #000088;">$worksheet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">UsedRange</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Row</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$min_col</span>    <span style="color: #339933;">=</span> <span style="color: #000088;">$worksheet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">UsedRange</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Column</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$max_row</span>    <span style="color: #339933;">=</span> <span style="color: #000088;">$worksheet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">UsedRange</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Rows</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Count</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$max_col</span>    <span style="color: #339933;">=</span> <span style="color: #000088;">$worksheet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">UsedRange</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Columns</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Count</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$min_row</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$row</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$max_row</span><span style="color: #339933;">;</span> <span style="color: #000088;">$row</span> <span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$column</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$min_col</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$column</span> <span style="color: #339933;">&lt;=</span> <span style="color: #000088;">$max_col</span><span style="color: #339933;">;</span> <span style="color: #000088;">$column</span> <span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
       <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$worksheet</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Cells</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">,</span> <span style="color: #000088;">$column</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">value</span><span style="color: #339933;">;</span>
       <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$value</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$excel_app</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Workbooks</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$excel_app</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Quit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://ray.imiddle.net/2009/11/how-to-read-the-excel-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework 1.9发布</title>
		<link>http://ray.imiddle.net/2009/08/zend-framework-19-released/</link>
		<comments>http://ray.imiddle.net/2009/08/zend-framework-19-released/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 03:49:17 +0000</pubDate>
		<dc:creator>Ray</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://ray.imiddle.net/?p=576</guid>
		<description><![CDATA[感觉现在Zend Framework 更新了很快，可能和日益受到关注有关。不知不觉中已经发布到了1.9版本。 更新的内容可以查看：http://devzone.zend.com/article/4906-Zend-Framework-1.9.0-Released 我对Zend_Test_PHPUnit_Db和Zend_Queue比较感兴趣，特别是Zend_Queue的支持，特别是加入了对MemcacheQ的原生支持。 有空学习一下这些新内容，感觉Zend Framework在逐渐缩短和RoR之间的差距。在新版本发布之际，更新一下Zend Framework的帮助chm. 中文Chm: http://ray.imiddle.net/download/zend_framework_1_9_cn.chm 英文Chm: http://ray.imiddle.net/download/zend_framework_1_9_en.chm]]></description>
			<content:encoded><![CDATA[<p>感觉现在Zend Framework 更新了很快，可能和日益受到关注有关。不知不觉中已经发布到了1.9版本。</p>
<p>更新的内容可以查看：<a href="http://devzone.zend.com/article/4906-Zend-Framework-1.9.0-Released">http://devzone.zend.com/article/4906-Zend-Framework-1.9.0-Released</a></p>
<p>我对<code>Zend_Test_PHPUnit_Db和</code><code>Zend_Queue比较感兴趣，特别是Zend_Queue的支持，特别是加入了对</code>MemcacheQ的原生支持。</p>
<p>有空学习一下这些新内容，感觉Zend Framework在逐渐缩短和RoR之间的差距。在新版本发布之际，更新一下Zend Framework的帮助chm.</p>
<ul>
<li>中文Chm: <a href="http://ray.imiddle.net/download/zend_framework_1_9_cn.chm">http://ray.imiddle.net/download/zend_framework_1_9_cn.chm</a></li>
<li>英文Chm: <a href="http://ray.imiddle.net/download/zend_framework_1_9_en.chm">http://ray.imiddle.net/download/zend_framework_1_9_en.chm</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://ray.imiddle.net/2009/08/zend-framework-19-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

