<?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>::CODER:: 誠智數位 &#187; Category &#187; PHP</title>
	<atom:link href="https://blog.coder.com.tw/category/technology/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.coder.com.tw</link>
	<description>一群阿宅的工作、生活筆記</description>
	<lastBuildDate>Sat, 24 Oct 2020 04:55:21 +0000</lastBuildDate>
	<language>zh-TW</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.7.41</generator>
	<item>
		<title>[windows]sublime Text2安裝PHP Beautifier說明</title>
		<link>https://blog.coder.com.tw/system/windowssublime-text2%e5%ae%89%e8%a3%9dphp-beautifier%e8%aa%aa%e6%98%8e/</link>
		<comments>https://blog.coder.com.tw/system/windowssublime-text2%e5%ae%89%e8%a3%9dphp-beautifier%e8%aa%aa%e6%98%8e/#comments</comments>
		<pubDate>Mon, 16 Dec 2013 08:18:17 +0000</pubDate>
		<dc:creator><![CDATA[海]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[技術文章]]></category>
		<category><![CDATA[系統/軟體設定]]></category>

		<guid isPermaLink="false">http://www.coder.com.tw/blog/?p=141</guid>
		<description><![CDATA[sublime Text2的PHP Formate模組大家一般推的有2個,PHPTidy 和PHP Beaut... <a class="more" href="https://blog.coder.com.tw/system/windowssublime-text2%e5%ae%89%e8%a3%9dphp-beautifier%e8%aa%aa%e6%98%8e/">Continue reading &#8594;</a>]]></description>
				<content:encoded><![CDATA[<p>sublime Text2的PHP Formate模組大家一般推的有2個,PHPTidy 和PHP Beautifier<br />
本來因為PHP Beautifier安裝太麻煩,想直接安裝PHPTidy,結果PHPTidy在我的電腦怎麼裝都沒反應,<br />
百般無奈之下只好選擇另外一個安裝很麻煩的套件::::PHP Beautifier:::::::::::::</p>
<p>過程中遇到了無數的小問題,現在我把我遇到的問題和安裝過程整理如下:<br />
希望對各位覺得安裝很麻煩的人會有幫助</p>
<p>簡單來說,它的安裝有幾個步驟<br />
1.安裝PHP的PEAR(如果己經安裝過的可以套過此步驟)<br />
2.用PEAR 安裝PHP Beautifier套件<br />
3.用Sublime Text2的Package Control安裝PHP Beautifier功能<br />
4.調整參數</p>
<p>以下我針對各個步驟做詳細一點的說明<br />
<strong>1.安裝PHP的PEAR</strong></p>
<p>打開Windows命令字元提示視窗(cmd.exe)<br />
<strong style="color: red;"><br />
PS.這裡有一個地方要注意,因為它會需要寫作系統資料夾,所以一定要用系統管理員身份執行,不然一定沒辦法成功。<br />
</strong><br />
到你的php目錄之下<br />
輸入</p>
<div style="border-width: 1px; border-style: solid; background-color: #000000; color: #ffffff; padding: 5px;">php go-pear.phar</div>
<p>如果錯誤訊息顯示為找不到這個檔案,請到<a href="http://pear.php.net/go-pear.phar">http://pear.php.net/go-pear.phar</a>這個網址去下載go-pear.phar,並放到您的PHP目錄中</p>
<p>接著就看說明一直按ENTER就好了,(我是這樣,但您可以依據自己的需求調整)</p>
<p>安裝成功訊息出現後,<span style="color: #339966;">到此目錄中找到PEAR_ENV.reg檔案,點它2下</span>,PEAR就安裝好了。</p>
<p><strong>2.用PEAR安裝PHP_Beautifier-0.1.15</strong><br />
在PHP中輸入</p>
<div style="border-width: 1px; border-style: solid; background-color: #000000; color: #ffffff; padding: 5px;">pear install PHP_Beautifier-0.1.15</div>
<p>接著就會提示安裝完成</p>
<p><a href="http://www.coder.com.tw/blog/wp-content/uploads/2013/12/未命名-22.jpg"><img class="alignnone size-full wp-image-143" alt="未命名-2" src="http://www.coder.com.tw/blog/wp-content/uploads/2013/12/未命名-22.jpg" width="636" height="440" /></a></p>
<p><strong>3.用Sublime Text2的Package Control安裝PHP Beautifier功能</strong></p>
<p>打開Sublime text2的Package Control (ctrl+shift+p),執行install Package,後輸入Php Beautifier後安裝</p>
<p>接著就會提示安裝完成。</p>
<p>4.調整參數</p>
<p>這樣就能用了嗎? 別急,還需要調整一些內容&#8230;.<br />
google大神拜到的</p>
<p><code><br />
# 修正出現 Cannot redeclare class Config 錯誤<br />
# 切進 PHP_Beautifier 的 Filter 目錄<br />
#打開PHP安裝目錄的pear/PHP/Beautifier/Filter</code></p>
<p># 打開下面兩個檔案<br />
- Pear.filter.php<br />
- phpBB.filter.php</p>
<p># 注解掉下句這句<br />
require_once (&#8216;PEAR/Config.php&#8217;);</p>
<p>接著修改php_beautifier.py文件</p>
<p>打開sublime text2上方工具列的Preferences-&gt;Browse Packages</p>
<p>接著會跳出檔案管理員,打開PhpBeautifier/php_beautifier.py這個檔案</p>
<p>找到第26行的<br />
<code><br />
cmd = "php_beautifier"<br />
</code><br />
修改為<br />
<code><br />
cmd = "PHP安裝目錄中的/php_beautifier.bat"<br />
</code><br />
然後就可以用了@@</p>
<p>&nbsp;</p>
<p>使用方法為</p>
<p>開啟您要格式化的PHP檔案後,在那頁選擇Ctrl+Shift+P後,輸入Format PHP,就可以看到效果了。</p>
<p>大家趕快去試試看吧^____________^</p>
<p>&nbsp;</p>
<p>如果需要過操作過程的圖示,參考資料有很多,可以前往觀賞</p>
<p>參考資料</p>
<p><a href="http://blog.wu-boy.com/2009/03/windows-appserv-%E5%AE%89%E8%A3%9D-pear-%E5%A5%97%E4%BB%B6/">http://blog.wu-boy.com/2009/03/windows-appserv-%E5%AE%89%E8%A3%9D-pear-%E5%A5%97%E4%BB%B6/</a></p>
<p><a href="http://blog.csdn.net/zm2714/article/details/8076077">http://blog.csdn.net/zm2714/article/details/8076077</a></p>
<p><a href="http://wangye.org/blog/archives/266/">http://wangye.org/blog/archives/266/</a></p>
]]></content:encoded>
			<wfw:commentRss>https://blog.coder.com.tw/system/windowssublime-text2%e5%ae%89%e8%a3%9dphp-beautifier%e8%aa%aa%e6%98%8e/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sublime Text安裝SublimeLinter進行PHP程式碼檢查</title>
		<link>https://blog.coder.com.tw/system/sublime-text%e5%ae%89%e8%a3%9dsublimelinter%e9%80%b2%e8%a1%8cphp%e7%a8%8b%e5%bc%8f%e7%a2%bc%e6%aa%a2%e6%9f%a5/</link>
		<comments>https://blog.coder.com.tw/system/sublime-text%e5%ae%89%e8%a3%9dsublimelinter%e9%80%b2%e8%a1%8cphp%e7%a8%8b%e5%bc%8f%e7%a2%bc%e6%aa%a2%e6%9f%a5/#comments</comments>
		<pubDate>Fri, 13 Dec 2013 14:10:27 +0000</pubDate>
		<dc:creator><![CDATA[海]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[系統/軟體設定]]></category>

		<guid isPermaLink="false">http://www.coder.com.tw/blog/?p=132</guid>
		<description><![CDATA[Sublime Text是個輕量又強大的程式碼編輯器 其它的好插件我不說了,但是安裝SublimeLinter... <a class="more" href="https://blog.coder.com.tw/system/sublime-text%e5%ae%89%e8%a3%9dsublimelinter%e9%80%b2%e8%a1%8cphp%e7%a8%8b%e5%bc%8f%e7%a2%bc%e6%aa%a2%e6%9f%a5/">Continue reading &#8594;</a>]]></description>
				<content:encoded><![CDATA[<p>Sublime Text是個輕量又強大的程式碼編輯器<br />
其它的好插件我不說了,但是安裝SublimeLinter時遇到一些問題,所以寫下來記錄一下。</p>
<p>照網路上的部驟安裝完後,也設定了Preferences-&gt;Package Settings-&gt;SublimeLinter-&gt;Settings – User<br />
<a href="http://www.coder.com.tw/blog/wp-content/uploads/2013/12/未命名-2.jpg"><img class="alignnone size-full wp-image-133" alt="未命名-2" src="http://www.coder.com.tw/blog/wp-content/uploads/2013/12/未命名-2.jpg" width="400" height="172" /></a></p>
<p>但是在程式碼輸入完儲存時,偵錯依然沒有作用</p>
<p>開啟Console後,發現有一些錯誤訊息,原來跟儲存檔案時編碼有關&#8230;.＿</p>
<p>類似<br />
<code><br />
Traceback (most recent call last):<br />
File ".\sublime_plugin.py", line 190, in on_post_save<br />
File ".\sublime_plugin.py", line 154, in run_timed_function<br />
File ".\sublime_plugin.py", line 189, in<br />
File ".\SublimeLinter.py", line 744, in on_post_save<br />
File ".\SublimeLinter.py", line 611, in reload_view_module<br />
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 9: ordinal not in range(128)<br />
</code></p>
<p>google大神拜了之後,找到我一輩子也無法自己發現的解決方案</p>
<p>1.Preferences-&gt;Browser Packages</p>
<p>2.找到SublimeLinter/SublimeLinter.py 並開啟它</p>
<p>3.找到這個function</p>
<pre class="brush: plain; title: ; notranslate">
def reload_view_module(view):
 for name, linter in LINTERS.items():
 module = sys.modules[linter.__module__]

if module.__file__.encode('utf-8') == (view.file_name() or '').encode('utf-8'):
 print 'SublimeLinter: reloading language:', linter.language
 MOD_LOAD.reload_module(module)
 lint_views(linter)
 break

</pre>
<p>4.將這個function連內容替換如下</p>
<pre class="brush: plain; title: ; notranslate">
def reload_view_module(view):
    for name, linter in LINTERS.items():
        module = sys.modules[linter.__module__]
        module_file = module.__file__
        if isinstance(module_file, unicode):
            module_file = module_file.encode('utf-8')
        if module_file == view.file_name().encode('utf-8'):
            print 'SublimeLinter: reloading language:', linter.language
            MOD_LOAD.reload_module(module)
            lint_views(linter)
            break
</pre>
<p>鏘鏘!!!大功告成,有錯誤訊息了!!!</p>
<p><a href="http://www.coder.com.tw/blog/wp-content/uploads/2013/12/未命名-21.jpg"><img class="alignnone size-full wp-image-136" alt="未命名-2" src="http://www.coder.com.tw/blog/wp-content/uploads/2013/12/未命名-21.jpg" width="796" height="416" /></a></p>
]]></content:encoded>
			<wfw:commentRss>https://blog.coder.com.tw/system/sublime-text%e5%ae%89%e8%a3%9dsublimelinter%e9%80%b2%e8%a1%8cphp%e7%a8%8b%e5%bc%8f%e7%a2%bc%e6%aa%a2%e6%9f%a5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>透過PHP上傳video至facebook</title>
		<link>https://blog.coder.com.tw/technology/facebook/%e9%80%8f%e9%81%8ephp%e4%b8%8a%e5%82%b3video%e8%87%b3facebook/</link>
		<comments>https://blog.coder.com.tw/technology/facebook/%e9%80%8f%e9%81%8ephp%e4%b8%8a%e5%82%b3video%e8%87%b3facebook/#comments</comments>
		<pubDate>Thu, 05 Dec 2013 04:23:19 +0000</pubDate>
		<dc:creator><![CDATA[海]]></dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.coder.com.tw/blog/?p=106</guid>
		<description><![CDATA[在facebook中上傳video,可以透過Facebook提供的PHP SDK上傳 上傳方法跟上傳圖片差不多... <a class="more" href="https://blog.coder.com.tw/technology/facebook/%e9%80%8f%e9%81%8ephp%e4%b8%8a%e5%82%b3video%e8%87%b3facebook/">Continue reading &#8594;</a>]]></description>
				<content:encoded><![CDATA[<p>在facebook中上傳video,可以透過Facebook提供的PHP SDK上傳</p>
<p>上傳方法跟上傳圖片差不多</p>
<p>上傳的檔案跟圖片一樣,一定得放在同一個domain裡</p>
<pre class="brush: php; title: ; notranslate">

require_once('facebook.php');
 $config =--&gt; array(
   'appId' =&gt; '您的APPID',
   'secret' =&gt;'您的APP Secret',
   'fileUpload' =&gt; true,
   'allowSignedRequest' =&gt; false
);

$facebook = new Facebook($config);
$user_id = $facebook-&gt;getUser();

$video = '123.wmv';  //您的影片
$video_title = 'test'; //上傳的影片標題
$video_desc = &quot;test&quot;; //上傳的影片描述
?&gt;
&lt;html&gt;
&lt;head&gt;&lt;/head&gt;
&lt;body&gt;

&lt;?php

//如果已經登入就進行上傳
if($user_id) {

   try {

      $ret_obj = $facebook-&gt;api('/me/videos', 'POST', array(
         'source' =&gt; '@' . $video,
         'title' =&gt; $video_title,
         'description' =&gt; $video_desc
      )
      );
      echo '&lt;pre&gt;Photo ID: ' . $ret_obj['id'] . '&lt;/pre&gt;';
      echo '&lt;br /&gt;&lt;a href=&quot;' . $facebook-&gt;getLogoutUrl() . '&quot;&gt;logout&lt;/a&gt;';
   } catch(FacebookApiException $e) {
      $login_url = $facebook-&gt;getLoginUrl( array('scope' =&gt; 'publish_stream'));
      echo 'Please &lt;a href=&quot;' . $login_url . '&quot;&gt;login.&lt;/a&gt;';
      error_log($e-&gt;getType());
      error_log($e-&gt;getMessage());
   }
} else 
{ //未登入就先用連結登入

   $login_url = $facebook-&gt;getLoginUrl( array( 'scope' =&gt; 'publish_stream') );
   echo 'Please &lt;a href=&quot;' . $login_url . '&quot;&gt;login.&lt;/a&gt;';

}
</pre>
<p><strong>上傳後的結果圖如下</strong></p>
<p><a href="http://www.coder.com.tw/blog/wp-content/uploads/2013/12/123.jpg"><img class="alignnone size-full wp-image-119" style="border: 1px solid black;" alt="123" src="http://www.coder.com.tw/blog/wp-content/uploads/2013/12/123.jpg" width="486" height="426" /></a></p>
]]></content:encoded>
			<wfw:commentRss>https://blog.coder.com.tw/technology/facebook/%e9%80%8f%e9%81%8ephp%e4%b8%8a%e5%82%b3video%e8%87%b3facebook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php升級5.3後localhost連線很慢</title>
		<link>https://blog.coder.com.tw/technology/php/php%e5%8d%87%e7%b4%9a5-3%e5%be%8clocalhost%e9%80%a3%e7%b7%9a%e5%be%88%e6%85%a2/</link>
		<comments>https://blog.coder.com.tw/technology/php/php%e5%8d%87%e7%b4%9a5-3%e5%be%8clocalhost%e9%80%a3%e7%b7%9a%e5%be%88%e6%85%a2/#comments</comments>
		<pubDate>Fri, 08 Nov 2013 12:31:10 +0000</pubDate>
		<dc:creator><![CDATA[海]]></dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.coder.com.tw/blog/?p=91</guid>
		<description><![CDATA[因為PHP 5.3以後連線時會多一個IPV4或IPV6的判斷 DB連線主機設localhost會造成遲緩 把連... <a class="more" href="https://blog.coder.com.tw/technology/php/php%e5%8d%87%e7%b4%9a5-3%e5%be%8clocalhost%e9%80%a3%e7%b7%9a%e5%be%88%e6%85%a2/">Continue reading &#8594;</a>]]></description>
				<content:encoded><![CDATA[<p>因為PHP 5.3以後連線時會多一個IPV4或IPV6的判斷</p>
<p>DB連線主機設localhost會造成遲緩</p>
<p>把連線參數從</p>
<p>$DBSERVER = &#8220;localhost";</p>
<p>改成</p>
<p>$DBSERVER = &#8220;127.0.0.1&#8243;;</p>
<p>即可</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.coder.com.tw/technology/php/php%e5%8d%87%e7%b4%9a5-3%e5%be%8clocalhost%e9%80%a3%e7%b7%9a%e5%be%88%e6%85%a2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
