Archive

Archive for the ‘php’ Category

BIG-5編碼~許功蓋

June 13th, 2009

已經好久沒有遇到類似的問題了:P 現在都改用UTF-8了啊!

不過既然遇到了就來說明一下我的解決方法,個人覺得處理的有點怪

我是透過php去讀取Windows下的資料夾,但是當路徑中有 “許” 的字樣時竟然會出現錯誤

後來發現是多了一條斜線,因此無法正常開啟資料夾

許\錯誤

因此利用取代的方式,把\取代掉就好囉!

$address = iconv("utf-8","big-5",str_replace("\\","",iconv("big5","utf-8",$address)));

不過因為網頁是UTF-8,讀取檔案總管是BIG-5,所以才要這樣轉來轉去的!

感覺有點蠢 :P

Squall php, 技術文件

使用PHP從Gmail發信

March 5th, 2009

參考自deepakssn : Send email using PHP with Gmail

1. 首先下載 PHPMailer ( http://phpmailer.sourceforge.net )
2. 解壓縮至 phpmailer 資料夾 (自己找的到就好)
3. 新建一個 PHP ( ex: email.php)
4. 修改email.php
Read more…

Squall php , ,

[PHP] number_format

April 28th, 2008

當你計算依些數值的時候,有些時候會想要取到小數點第二位之類的

就可以使用number_format囉! 之前我都是使用printf(“%.2f”,$num);

最近發現 number_format 也很好用喔!!

而且還可以設定自己想要的格式,如果我要取到小數點第二位的話

number_format($num,2);

其他相關用法:

$number = 1234.56;

// 預設
$english_format_number = number_format($number);
// 印出 1,235

// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56

$number = 1234.5678;

// english notation without thousands seperator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57

?>

更多bumber_format相關教學

Squall php, 技術文件 ,

[心得] use C/C++ write PHP Extension

September 13th, 2007

這幾天再研究如何寫php extension..

可惜忙了三~四天都沒有一個結果..XD

今天終於找到問題所在…

原來是我visuall c++在compile的時候選錯了模式

Win32_Release_TS and Win32_Debug_TS ,之前一直都用debug

導致php無法使用dll檔~ (雖然在網站上有看到說明,可是卻沒有特別留意)

不過用了之後,在把他丟到php\extencsion就可以用啦!! :)

Squall php, 工作紀錄, 技術文件

SESSION_START

July 28th, 2007

今天把uniserver3.2升級成uniserver3.5囉!
大致上似乎沒有太大的差別,不過我是為了要使用JSON這個功能 (PHP 5.2以上才有支援的樣子)
www跟mysql\data資料全部複製過去就可以啟動囉 (所以我猜測資料庫版本沒有變動)
唯一遇到的錯誤訊息就是,session_start出現錯誤~~

cannot send session cache limiter-headers already sent

通常遇到這問題,是在用session之前,你已經先將其他資料印出來了~
不過後來發現其實還有其他原因也會造成這個問題~~

[引用了UTF-8格式的文件]
有些UTF-8格式的文件會在文件的開始放入判斷字元(BOM),可以啟用PHP.INI的設定
output_buffering = 4096 或是採用類似SMARTY樣版的方式來避免類似問題發生

不過我卻發現舊版的php.ini中裡面已經存在這行囉! (所以我之前當然可以用囉)

原文:台灣PHP聯盟

Squall php, web