<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
  <channel>
    <title><![CDATA[::SANKAI:: :: 痞客邦 PIXNET ::]]></title>
    <link>http://liaosankai.pixnet.net/blog</link>
    <description><![CDATA[自然‧原味‧低溫烘焙]]></description>
    <pubDate>Wed, 14 Oct 2009 02:03:42 +0000</pubDate>
    <managingEditor>liaosankai@not-valid.com (liaosankai)</managingEditor>
    <copyright>Copyright 2003-2009 liaosankai,Pixnet Digital Media Coporation. All rights reserved.</copyright>
    <generator>PIXNET Media Digital Coporation</generator>
    <language>zh</language>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <item>
      <title><![CDATA[IE6以前的版本，設定CSS的字型不能使用單引號或雙引號]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/25216234</link>
      <guid>http://liaosankai.pixnet.net/blog/post/25216234</guid>
      <description><![CDATA[最近開發一個網站，要符合各瀏覽器檢視的畫面都正常，所以包含了IE所有版本、Firefox、Chrome、Opera、Safari。
因為要統一字型，所以我使用了下面這個寫法]]></description>
      <content:encoded><![CDATA[最近開發一個網站，要符合各瀏覽器檢視的畫面都正常，所以包含了IE所有版本、Firefox、Chrome、Opera、Safari。<br />
因為要統一字型，所以我使用了下面這個寫法<br />  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/25216234">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Wed, 14 Oct 2009 02:03:42 +0000</pubDate>
      <category>研究雜記</category>
      <comments>http://liaosankai.pixnet.net/blog/post/25216234#comments</comments>
    </item>
    <item>
      <title><![CDATA[C.C.小甜心]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24624525</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24624525</guid>
      <description><![CDATA[ 
笑點？XD自己想]]></description>
      <content:encoded><![CDATA[<img src="http://pic.pimg.tw/liaosankai/4a5c7a37253cd.png" border="0" title="CC.png" alt="CC.png" /> <br />
笑點？XD自己想<br />  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24624525">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Tue, 14 Jul 2009 12:29:28 +0000</pubDate>
      <category>No Category</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24624525#comments</comments>
    </item>
    <item>
      <title><![CDATA[獲得珍寶一枚]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24541187</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24541187</guid>
      <description><![CDATA[ 
反正就很開心，所以畫了一張圖來表示自己的心情。我是快樂的國王，啦啦啦~]]></description>
      <content:encoded><![CDATA[<img src="http://pic.pimg.tw/liaosankai/4a50a908bf934.png" border="0" title="富有的國王.png" alt="富有的國王.png" /> <br />
反正就很開心，所以畫了一張圖來表示自己的心情。我是快樂的國王，啦啦啦~<br />  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24541187">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Sun, 05 Jul 2009 13:23:03 +0000</pubDate>
      <category>No Category</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24541187#comments</comments>
    </item>
    <item>
      <title><![CDATA[設定 Kohana 透過 Gmail 發信 注意事項]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24523247</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24523247</guid>
      <description><![CDATA[從小海的舊文章「設定 Kohana 透過 Gmail 發信」知道從Kohana透過Gmail發信是那麼如此容易，所以今天就很開心按著小海設定來當參考，弄個小小發信程式，然後按下「送出」
]]></description>
      <content:encoded><![CDATA[從小海的舊文章「<a href="http://tzangms.com/programming/1423">設定 Kohana 透過 Gmail 發信</a>」知道從Kohana透過Gmail發信是那麼如此容易，所以今天就很開心按著小海設定來當參考，弄個小小發信程式，然後按下「送出」<br />
<br />  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24523247">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Thu, 02 Jul 2009 16:19:18 +0000</pubDate>
      <category>Kohana</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24523247#comments</comments>
    </item>
    <item>
      <title><![CDATA[array_split = array_chunk]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24193437</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24193437</guid>
      <description><![CDATA[最近要將陣列為表格顯示，所以為了方便表格的換行，所以事先將陣列分組可能會比較方便，所以就試著寫下面這個函式

/*
$input = array(1,2,3,4,5,6,7,8);

print_r(array_split($input,3));

輸出=>
array(
    array(1,2,3)
    array(4,5,6)
    array(7,8)
);
*/
function array_split($array,$step){
    $run_step = count($array)/$step;
    for($i=0; $i]]></description>
      <content:encoded><![CDATA[<p>最近要將陣列為表格顯示，所以為了方便表格的換行，所以事先將陣列分組可能會比較方便，所以就試著寫下面這個函式</p>
<pre class="brush:php">
/*
$input = array(1,2,3,4,5,6,7,8);

print_r(array_split($input,3));

輸出=>
array(
    array(1,2,3)
    array(4,5,6)
    array(7,8)
);
*/
function array_split($array,$step){
    $run_step = count($array)/$step;
    for($i=0; $i<$run_step; $i++) {
        $new_array[] = array_slice($array,$i*$step,$step);
    }
    return $new_array;
}
</pre>
<p>後來用google找了一下，Jonas John 也寫了這個函式<a href="http://www.jonasjohn.de/snippets/php/array-split-into-parts.htm"> ArraySplitIntoParts_Shorter</a>。嗯…發現我的寫法和Jonas John又不太一樣。不過突然發現Jonas John在開頭註解寫著「already exist as
build-in function」，換問話說="=我也跟Jonas John一樣白寫了，這個函式是PHP的內建的啦，叫做「<a href="http://tw.php.net/manual/en/function.array-chunk.php">array_chunk</a>」，我也來個Oops~~\o/</p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24193437">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Mon, 01 Jun 2009 05:58:29 +0000</pubDate>
      <category>PHP筆記</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24193437#comments</comments>
    </item>
    <item>
      <title><![CDATA[Kohana Captcha module - securimage]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24181115</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24181115</guid>
      <description><![CDATA[Well...Maybe it's an unnecessary library in Kohana,but I still try to make it be module.
The original source from http://www.phpcaptcha.org/,so It's GNU LESSER GENERAL PUBLIC LICENSE
呃…或許這個模組在Kohana是多餘的，但是我還是把他做出來了= =，他一樣是用http://www.phpcaptcha.org/的原始碼修改的，所以授權一樣是LGPL]]></description>
      <content:encoded><![CDATA[<p>Well...Maybe it's an unnecessary library in Kohana,but I still try to make it be module.
The original source from http://www.phpcaptcha.org/,so It's GNU LESSER GENERAL PUBLIC LICENSE</p>
<p>呃…或許這個模組在Kohana是多餘的，但是我還是把他做出來了= =，他一樣是用http://www.phpcaptcha.org/的原始碼修改的，所以授權一樣是LGPL</p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24181115">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Tue, 19 May 2009 17:14:00 +0000</pubDate>
      <category>Kohana</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24181115#comments</comments>
    </item>
    <item>
      <title><![CDATA[國軍青年日報網站]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24181108</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24181108</guid>
      <description><![CDATA[話說...我從google新聞看著看著無意間連到這個網站，而且他相當在乎使用者的感覺，所以做了一個很貼心的投票，如下圖：
 
呃...至少也要考慮一下其它瀏覽器的使用者吧/_\]]></description>
      <content:encoded><![CDATA[<p>話說...我從google新聞看著看著無意間連到這個網站，而且他相當在乎使用者的感覺，所以做了一個很貼心的投票，如下圖：</p>
<img src="http://pic.pimg.tw/liaosankai/normal_4a2168f473ece.png" border="0" /> 
<p>呃...至少也要考慮一下其它瀏覽器的使用者吧/_\</p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24181108">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Sat, 16 May 2009 17:12:00 +0000</pubDate>
      <category>雜碎唸</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24181108#comments</comments>
    </item>
    <item>
      <title><![CDATA[filectime 和 filemtime 的差異]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24181094</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24181094</guid>
      <description><![CDATA[最近會使用到「取得檔案最後修改的時間」，從PHP手冊發現有兩個功能描述幾乎一模一樣的函式filectime()與filemtime，當然很自然的好奇倒底是差在哪邊，所以就用G大仙查了一下，很慶幸在「這篇討論文」有找到由coopster所提出的解答:)，而且還特別說明了fileatime這個函式

fileatime

The atime of a file is supposed to change whenever the data blocks of a file are being read. This can be costly performancewise when an application regularly accesses a very large number of files or directories. Some Unix filesystems can be mounted with atime updates disabled to increase the performance of such applications; USENET news spools are a common example. On such filesystems this function will be useless.]]></description>
      <content:encoded><![CDATA[<p>最近會使用到「取得檔案最後修改的時間」，從PHP手冊發現有兩個功能描述幾乎一模一樣的函式filectime()與filemtime，當然很自然的好奇倒底是差在哪邊，所以就用G大仙查了一下，很慶幸在「<a href="http://www.webmasterworld.com/forum88/2070.htm">這篇討論文</a>」有找到由coopster所提出的解答:)，而且還特別說明了fileatime這個函式</p>
<!--more-->
<strong>fileatime</strong>
<p>
The atime of a file is supposed to change whenever the data blocks of a file are being read. This can be costly performancewise when an application regularly accesses a very large number of files or directories. Some Unix filesystems can be mounted with atime updates disabled to increase the performance of such applications; USENET news spools are a common example. On such filesystems this function will be useless.</p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24181094">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Tue, 12 May 2009 17:10:00 +0000</pubDate>
      <category>PHP筆記</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24181094#comments</comments>
    </item>
    <item>
      <title><![CDATA[Firebug Lite]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24181081</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24181081</guid>
      <description><![CDATA[原本以為FireBug只有在好用的firefox才有的plugin，今天我二哥說…官方早就有一個叫Firebug Lite。囧rz...我竟然這麼晚才發現，害我每次在Firefox跑很順的網頁，在IE跑不出來，然後這個笨IE的錯誤訊息又令人抓狂。(不過通常在firefox正常的，ie不正常的原因往往都只有一個，就是在物件陣列裡了一個逗號)

var obj = {     
     param1: '參數1',
     param2: '參數2', //最後多了一個逗號，在IE就會出錯
}

anyway...這個是常常裡到才會記得的ie問題，但是如果不是這個原因就頭大了/__\，不過Firebug Lite的安裝方法比較不同，他並不是像firefox的插件，而是用javascript所模擬的，安裝方法就是直接在網頁中載入官方所提供的「firebug-lite.js」，載入的方式有三種：


//第一種是直接以絕對網頁的方式指定官網的firebug lib網址：
http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js



//第二種是把firebug-lite.js下載回來自己的電腦，再載入：
myproject/js/firebug-lite-compressed.js



//第三種是把官方提供的快速鍵，加入到我的最愛
Firebug Lite as bookmarklet
Drag the following link to your bookmark toolbar and use Firebug Lite on any page:

Firebug Lite ]]></description>
      <content:encoded><![CDATA[<p>原本以為FireBug只有在好用的firefox才有的plugin，今天我二哥說…官方早就有一個叫<a href="http://getfirebug.com/lite.html">Firebug Lite</a>。囧rz...我竟然這麼晚才發現，害我每次在Firefox跑很順的網頁，在IE跑不出來，然後這個笨IE的錯誤訊息又令人抓狂。(不過通常在firefox正常的，ie不正常的原因往往都只有一個，就是在物件陣列裡了一個逗號)</p>
<pre class="brush:html">
var obj = {     
     param1: '參數1',
     param2: '參數2', //最後多了一個逗號，在IE就會出錯
}
</pre>
anyway...這個是常常裡到才會記得的ie問題，但是如果不是這個原因就頭大了/__\，不過Firebug Lite的安裝方法比較不同，他並不是像firefox的插件，而是用javascript所模擬的，安裝方法就是直接在網頁中載入官方所提供的「firebug-lite.js」，載入的方式有三種：
<!--more-->
<pre class="brush:html">
//第一種是直接以絕對網頁的方式指定官網的firebug lib網址：
http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js
</pre>

<pre class="brush:html">
//第二種是把firebug-lite.js下載回來自己的電腦，再載入：
myproject/js/firebug-lite-compressed.js
</pre>

<pre class="brush:html">
//第三種是把官方提供的快速鍵，加入到我的最愛
Firebug Lite as bookmarklet
Drag the following link to your bookmark toolbar and use Firebug Lite on any page:

Firebug Lite <= 在這個連結按右鍵，加至我的最愛
</pre>

<p>唯一美中不足的地方就是他好像沒有檢視browser送出資料的功能(post,get所傳送的值)=..=
不過重點是在ie能抓蟲就好了 \  /  </p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24181081">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Sat, 02 May 2009 17:09:00 +0000</pubDate>
      <category>研究雜記</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24181081#comments</comments>
    </item>
    <item>
      <title><![CDATA[哪一種程式語言最好？]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24181060</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24181060</guid>
      <description><![CDATA[哪一種程式語言比較好呢？

通常會提出這個問題的是一個剛想踏入暗黑程式界的初心者程式設計師
希望在一開始就能夠選擇對的路，拜對師門。我的經驗告訴我，不論你
選擇哪個門派，唯有一種結果是肯定的]]></description>
      <content:encoded><![CDATA[<p>哪一種程式語言比較好呢？</p>

<p>通常會提出這個問題的是一個剛想踏入暗黑程式界的初心者程式設計師
希望在一開始就能夠選擇對的路，拜對師門。我的經驗告訴我，不論你
選擇哪個門派，唯有一種結果是肯定的</p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24181060">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Fri, 24 Apr 2009 17:00:00 +0000</pubDate>
      <category>研究雜記</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24181060#comments</comments>
    </item>
    <item>
      <title><![CDATA[囧啊，又有新的PHP framework了，Yii]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24180990</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24180990</guid>
      <description><![CDATA[我有趴別人blog的興趣，無意間看見這篇由Fred Wu所寫的「Choosing a PHP Framework Round 2: Yii vs Kohana vs CodeIgniter」，文章內容在描述同屬輕量級的framework的Yii vs Kohana vs CodeIgniter，嗯…Kohana 是從CodeIgniter分出來的還好，但Yii說真的我是今天才知道有這東西。這裡有一篇官方提供的各framework比較文章，Yii贏的部分似乎是在資料庫支援的完整性與效能。回去看一下Yii官網下面的時間2008-2009，果然是在Kohana之後所產生的新的framework。

Fred Wu的blog中還有幾篇相關文章，像是如何把Kohana的helper橋接到Yii和讓Yii橋接成有完整的Kohana風格追加，看來Fred Wu似乎很中意Yii呀~@_@已經開始將Kohana與Yii合體了。]]></description>
      <content:encoded><![CDATA[<p>我有趴別人blog的興趣，無意間看見這篇由Fred Wu所寫的「<a href="http://www.beyondcoding.com/2009/03/02/choosing-a-php-framework-round-2-yii-vs-kohana-vs-codeigniter/">Choosing a PHP Framework Round 2: Yii vs Kohana vs CodeIgniter</a>」，文章內容在描述同屬輕量級的framework的Yii vs Kohana vs CodeIgniter，嗯…Kohana 是從CodeIgniter分出來的還好，但Yii說真的我是今天才知道有這東西。這裡有一篇官方提供的<a href="http://blog.orite.com.au/tag/zend-framework/">各framework比較文章</a>，Yii贏的部分似乎是在資料庫支援的完整性與效能。回去看一下Yii官網下面的時間2008-2009，果然是在Kohana之後所產生的新的framework。</p>

<p>Fred Wu的blog中還有幾篇相關文章，像是<a href="http://www.beyondcoding.com/2009/03/06/release-yii-extension-yii-kohana-bridge-use-kohana-helpers-in-yii/">如何把Kohana的helper橋接到Yii</a>和<a href="http://www.beyondcoding.com/2009/03/11/yii-kohana-bridge-updated-full-kohana-flavour-now-added/">讓Yii橋接成有完整的Kohana風格追加</a>，看來Fred Wu似乎很中意Yii呀~@_@已經開始將Kohana與Yii合體了。</p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24180990">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Fri, 24 Apr 2009 16:58:00 +0000</pubDate>
      <category>PHP筆記</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24180990#comments</comments>
    </item>
    <item>
      <title><![CDATA[simple fileinfo() 取得檔案完整資訊]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24180973</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24180973</guid>
      <description><![CDATA[最近寫的程式會處理圖片上傳下載的動作，通常都會各別使用到pathinfo()、filesize()、getimagesize()，但是每次都要各別呼叫有點麻煩，所以就寫了一個helper來一次解決這個問題，這個function是針對Kohana寫的，如果你不是使用KHN的話，你可以複製程式碼後，自行修改符合你需要的部分

/*
Array
(
    [dirname] => .
    [basename] => bee.jpg
    [extension] => jpg
    [filename] => bee
    [filesize] => 883496
    [width] => 1920
    [height] => 1200
    [0] => 1920
    [1] => 1200
    [2] => 2
    [3] => width="1920" height="1200"
    [bits] => 8
    [channels] => 3
    [mime] => image/jpeg
)
*/



 class file extends file_Core {
/**
 * Info
 *
 * Get the File detail Info
 *
 * @access	public
 * @param	string 
 */	 
	public static function info($filename=NULL) {
		$imgaeType = array('jpg','gif','png');
		if(file_exists($filename)) {
			if(is_file($filename)) {
				//get basic info
				$info = pathinfo($filename);
				//add file size
				$info['filesize'] = filesize($filename);
				//add image info
				if(in_array($info['extension'],$imgaeType)) {
					$imageInfo = getimagesize($filename);
					$info['width'] = $imageInfo[0];
					$info['height'] = $imageInfo[1];
					//return info
					return array_merge($info,$imageInfo);
				} else {
					return $info;
				}
			} else {
				die($filename.' is not file!!');
			}
		} else {
			die($filename.' is not exists!!');
		}
	}
}

另外在檔案size的部分，之後可以配合Kohana的helper中的text::bytes()格式化適合閱讀的文字 / v \]]></description>
      <content:encoded><![CDATA[<p>最近寫的程式會處理圖片上傳下載的動作，通常都會各別使用到pathinfo()、filesize()、getimagesize()，但是每次都要各別呼叫有點麻煩，所以就寫了一個helper來一次解決這個問題，這個function是針對Kohana寫的，如果你不是使用KHN的話，你可以複製程式碼後，自行修改符合你需要的部分</p>
<pre class="brush:php">
/*
Array
(
    [dirname] => .
    [basename] => bee.jpg
    [extension] => jpg
    [filename] => bee
    [filesize] => 883496
    [width] => 1920
    [height] => 1200
    [0] => 1920
    [1] => 1200
    [2] => 2
    [3] => width="1920" height="1200"
    [bits] => 8
    [channels] => 3
    [mime] => image/jpeg
)
*/
</pre>
<!--more-->
<pre class="brush:php">
 class file extends file_Core {
/**
 * Info
 *
 * Get the File detail Info
 *
 * @access	public
 * @param	string 
 */	 
	public static function info($filename=NULL) {
		$imgaeType = array('jpg','gif','png');
		if(file_exists($filename)) {
			if(is_file($filename)) {
				//get basic info
				$info = pathinfo($filename);
				//add file size
				$info['filesize'] = filesize($filename);
				//add image info
				if(in_array($info['extension'],$imgaeType)) {
					$imageInfo = getimagesize($filename);
					$info['width'] = $imageInfo[0];
					$info['height'] = $imageInfo[1];
					//return info
					return array_merge($info,$imageInfo);
				} else {
					return $info;
				}
			} else {
				die($filename.' is not file!!');
			}
		} else {
			die($filename.' is not exists!!');
		}
	}
}
</pre>
<p>另外在檔案size的部分，之後可以配合Kohana的helper中的text::bytes()格式化適合閱讀的文字 / v \</p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24180973">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Thu, 23 Apr 2009 16:55:00 +0000</pubDate>
      <category>PHP筆記</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24180973#comments</comments>
    </item>
    <item>
      <title><![CDATA[array_product()]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24180939</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24180939</guid>
      <description><![CDATA[最近趴了PHP官方的array函式，發現有多了一個array_product()，他出現在5.1.0之後的版本，可以將陣列裡的值進行相乘的動作，換句話說之前的階乘函式，可以有另外一種寫法了。

//*************************************************
//  函式名稱：階乘函式
//  功能說明：5! =  5 * 4 * 3 * 2 * 1 = echelon(5)
//*************************************************
function factorial(n){
    if(n == 1 || n == 0 ) {
        return 1;
    } else {
        return n * factorial(n - 1);
    }
}

改寫成這樣
array_product(range(1,5));
不過效能誰比較好呢？@_@，所以我利用之前文章提到的Xdebug來測試


function factorial($n){
    if($n == 1 || $n == 0 ) {
        return 1;
    } else {
        return $n * factorial($n - 1);
    }
}
factorial(30);
echo xdebug_time_index(); 
//0.00062918663024902

V.S

array_product(range(1,30));
echo xdebug_time_index();
//0.00033903121948242

=v=沒想到新的方法竟然又短又快耶，這算是一個新發現嗎XD]]></description>
      <content:encoded><![CDATA[<p>最近趴了PHP官方的array函式，發現有多了一個array_product()，他出現在5.1.0之後的版本，可以將陣列裡的值進行相乘的動作，換句話說<a href="http://liaosankai.pixnet.net/blog/post/14416596">之前的階乘函式</a>，可以有另外一種寫法了。</p>
<pre class="brush:php">
//*************************************************
//  函式名稱：階乘函式
//  功能說明：5! =  5 * 4 * 3 * 2 * 1 = echelon(5)
//*************************************************
function factorial(n){
    if(n == 1 || n == 0 ) {
        return 1;
    } else {
        return n * factorial(n - 1);
    }
}
</pre>
改寫成這樣
<pre class="brush:php">array_product(range(1,5));</pre>
不過效能誰比較好呢？@_@，所以我利用<a href="http://liaosankai.pixnet.net/blog/post/24178287">之前文章提到的Xdebug</a>來測試
<!--more-->
<pre class="brush:php">
function factorial($n){
    if($n == 1 || $n == 0 ) {
        return 1;
    } else {
        return $n * factorial($n - 1);
    }
}
factorial(30);
echo xdebug_time_index(); 
//0.00062918663024902
</pre>
V.S
<pre class="brush:php">
array_product(range(1,30));
echo xdebug_time_index();
//0.00033903121948242
</pre>
<p>=v=沒想到新的方法竟然又短又快耶，這算是一個新發現嗎XD</p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24180939">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Thu, 16 Apr 2009 16:51:00 +0000</pubDate>
      <category>PHP筆記</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24180939#comments</comments>
    </item>
    <item>
      <title><![CDATA[很像RO的Secret of the Solstice]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24180901</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24180901</guid>
      <description><![CDATA[ 
無意間看到一款國外遊戲，很像RO，而且是終生免費的(話說RO有名之後，後面就出現一堆像RO的)，啊勒=.=，竟然要2.xG的硬碟空間，一個像RO的遊戲竟然要用到快3G的，意思是他比RO更精美嗎，嘿嘿…所以就試著下載來玩看看。

 
不過下載好久喔.../__\ 更新也好久...囧rz]]></description>
      <content:encoded><![CDATA[<img src="http://pic.pimg.tw/liaosankai/4a21631d2804d.png" border="0" /> 
<p>無意間看到一款國外遊戲，很像RO，而且是終生免費的(話說RO有名之後，後面就出現一堆像RO的)，啊勒=.=，竟然要2.xG的硬碟空間，一個像RO的遊戲竟然要用到快3G的，意思是他比RO更精美嗎，嘿嘿…所以就試著下載來玩看看。</p>
<!--more-->
<img src="http://pic.pimg.tw/liaosankai/normal_4a216324d3408.png" border="0" title="2pdate.png" alt="2pdate.png" /> 
<p>不過下載好久喔.../__\ 更新也好久...囧rz</p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24180901">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Sat, 11 Apr 2009 16:46:00 +0000</pubDate>
      <category>雜碎唸</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24180901#comments</comments>
    </item>
    <item>
      <title><![CDATA[nl2br的反函式br2nl]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24180854</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24180854</guid>
      <description><![CDATA[最近使用到nl2br將文章轉存，突然發現好像沒有轉存的函式，用google來G一下，果然也有人遇到同樣的問題，從官方nl2br函式的回文中，就有一堆作者佛心來的=v=，提供了一些反轉函式。不好意思就偷偷給他選擇一個合適拿來用了(感謝)，因為我目前開始使用Kohana，所以下列就直接將他寫成helper了。


defined('SYSPATH') or die('No direct script access.');
class html extends html_Core {
	public static function br2nl($text) {    
		$string = str_replace(array("\r\n", "\r", "\n"), "", $string);
                return $string;
	} 
}

]]></description>
      <content:encoded><![CDATA[最近使用到nl2br將文章轉存，突然發現好像沒有轉存的函式，用google來G一下，果然也有人遇到同樣的問題，從<a href="http://tw.php.net/nl2br">官方nl2br函式</a>的回文中，就有一堆作者佛心來的=v=，提供了一些反轉函式。不好意思就偷偷給他選擇一個合適拿來用了(感謝)，因為我目前開始使用Kohana，所以下列就直接將他寫成helper了。
<!--more-->
<pre class="brush:php">
defined('SYSPATH') or die('No direct script access.');
class html extends html_Core {
	public static function br2nl($text) {    
		$string = str_replace(array("\r\n", "\r", "\n"), "<br />", $string);
                return $string;
	} 
}
</pre>
<br />  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24180854">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Thu, 09 Apr 2009 16:35:00 +0000</pubDate>
      <category>PHP筆記</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24180854#comments</comments>
    </item>
    <item>
      <title><![CDATA[office2007 files mimetype]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24180731</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24180731</guid>
      <description><![CDATA[最近用Kohana寫檔案上傳的程式，遇到一個奇怪的現象，就是只有docx、xlsx不能上傳，但是如果將檔案存成doc就可以上傳了，這時候還笨笨的沒想到原因，突然閃到一個mime的設定檔，馬上就猜是不是沒有定義。開啟了設定檔檢查了一下，果然沒有定義docx、xlsx等的mime，嗯…一開始是想說使用PHP的fileinfo取得檔案的mime後，再補上就好了。結果踢到鐵板呀/__\，fileinfo意外的都發生錯誤，悶了…所以我就直接google「docx mimetype list」，最後在這篇文章找到了定義值，我把他列在下面，或許改天有人也會用的到，就copy去吧!!]]></description>
      <content:encoded><![CDATA[<p>最近用Kohana寫檔案上傳的程式，遇到一個奇怪的現象，就是只有docx、xlsx不能上傳，但是如果將檔案存成doc就可以上傳了，這時候還笨笨的沒想到原因，突然閃到一個mime的設定檔，馬上就猜是不是沒有定義。開啟了設定檔檢查了一下，果然沒有定義docx、xlsx等的mime，嗯…一開始是想說使用PHP的fileinfo取得檔案的mime後，再補上就好了。結果踢到鐵板呀/__\，fileinfo意外的都發生錯誤，悶了…所以我就直接google「docx mimetype list」，最後在這<a href="http://www.projectpier.org/node/1112" target="_blank">篇文章</a>找到了定義值，我把他列在下面，或許改天有人也會用的到，就copy去吧!!</p><br />  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24180731">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Mon, 06 Apr 2009 16:33:00 +0000</pubDate>
      <category>Kohana</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24180731#comments</comments>
    </item>
    <item>
      <title><![CDATA[CI解決Image_lib的PNG透明alpha層無法顯示]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24180717</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24180717</guid>
      <description><![CDATA[CodeIgniter的Image_lib可以快速的產生所想要的縮圖，也可以方便的加入浮水印，不過官方原始的類別無法處理PNG的透明背景層，所有含有透明背景的圖片都會變成黑色的背景。
 
最近剛好使用到也遇到了問題/__\，幸好透過官方的討論區，找到其它玩家的解決方式。你可以從這篇討論文章的串文，看到原文的解決方式，不過我仍然將解決的方式，重新發表在這邊分享給遇到同樣問題的人。]]></description>
      <content:encoded><![CDATA[<p>CodeIgniter的Image_lib可以快速的產生所想要的縮圖，也可以方便的加入浮水印，不過官方原始的類別無法處理PNG的透明背景層，所有含有透明背景的圖片都會變成黑色的背景。</p>
<img src="http://pic.pimg.tw/liaosankai/4a215fabba7cc.png" border="0" /> 
<p>最近剛好使用到也遇到了問題/__\，幸好透過官方的討論區，找到其它玩家的解決方式。你可以從<a href="http://codeigniter.com/forums/viewthread/77836/">這篇討論文章的串文</a>，看到原文的解決方式，不過我仍然將解決的方式，重新發表在這邊分享給遇到同樣問題的人。</p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24180717">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Fri, 20 Mar 2009 16:32:00 +0000</pubDate>
      <category>CodeIgniter</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24180717#comments</comments>
    </item>
    <item>
      <title><![CDATA[Open-source free PHP CAPTCHA script]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24180695</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24180695</guid>
      <description><![CDATA[The library bug had be find by Tongshuai.It's seem because SESSION problem in different CI version.If you got the same trouble,you can try the solution that Tongshuai's comment (2009-04-24)
由網友Tongshuai測試之後發現有BUG，似乎是SESSION部分出了一些問題，很抱歉我沒有測試各CI版本，或許是CI版本的問題，但是Tongshuai也順便提供了他的解決方法，可以直接參考他的回覆內容(2009-04-24)]]></description>
      <content:encoded><![CDATA[<p style="color:red">The library bug had be find by <strong>Tongshuai</strong>.It's seem because SESSION problem in different CI version.If you got the same trouble,you can try the solution that Tongshuai's comment (2009-04-24)</p>
<p style="color:red">由網友Tongshuai測試之後發現有BUG，似乎是SESSION部分出了一些問題，很抱歉我沒有測試各CI版本，或許是CI版本的問題，但是Tongshuai也順便提供了他的解決方法，可以直接參考他的回覆內容(2009-04-24)</p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24180695">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Tue, 17 Mar 2009 16:28:00 +0000</pubDate>
      <category>CodeIgniter</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24180695#comments</comments>
    </item>
    <item>
      <title><![CDATA[PHP的foreach前身寫法]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24180657</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24180657</guid>
      <description><![CDATA[無意見看到一段程式碼，突然發覺這就是foreach嘛~滿特別的，因為以前沒這樣想過，所以記錄一下

//舊的寫法
while(list($key,$value) = each($attributes)){
    //do something
}
//PHP4版本新增
foreach($attributes as $key => $value){
   //do something
}

或許還在用PHP4之前版本的人玩家可以參考，有向下相容性(笑)]]></description>
      <content:encoded><![CDATA[無意見看到一段程式碼，突然發覺這就是foreach嘛~滿特別的，因為以前沒這樣想過，所以記錄一下
<pre class="brush:php">
//舊的寫法
while(list($key,$value) = each($attributes)){
    //do something
}
//PHP4版本新增
foreach($attributes as $key => $value){
   //do something
}
</pre>
或許還在用PHP4之前版本的人玩家可以參考，有向下相容性(笑)<br />  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24180657">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Sat, 14 Mar 2009 16:26:00 +0000</pubDate>
      <category>PHP筆記</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24180657#comments</comments>
    </item>
    <item>
      <title><![CDATA[查詢子關聯表資料數量的SQL語法]]></title>
      <link>http://liaosankai.pixnet.net/blog/post/24180652</link>
      <guid>http://liaosankai.pixnet.net/blog/post/24180652</guid>
      <description><![CDATA[最近下SQL讀取資料遇到了一個比較特殊的情況，問題已解決了，怕忘記在此馬上寫篇文章記錄，希望也能提供給遇到相同問題的人一些方向。
假設一個專案可有多個任務，如何在檢視專案清單時，同時列出專案底下共有多少任務數量，以及完成的任務數量]]></description>
      <content:encoded><![CDATA[<p>最近下SQL讀取資料遇到了一個比較特殊的情況，問題已解決了，怕忘記在此馬上寫篇文章記錄，希望也能提供給遇到相同問題的人一些方向。</p>
<p>假設一個專案可有多個任務，如何在檢視專案清單時，同時列出專案底下共有多少任務數量，以及完成的任務數量</p>  <div class="more"><a href="http://liaosankai.pixnet.net/blog/post/24180652">(Read More...)</a></div>]]></content:encoded>
      <pubDate>Sun, 08 Mar 2009 16:24:00 +0000</pubDate>
      <category>MySQL</category>
      <comments>http://liaosankai.pixnet.net/blog/post/24180652#comments</comments>
    </item>
  </channel>
</rss>
