使用 strrchr() 函式,可以取得檔案副檔名。
$filename = "noname.jpg"; //檔案檔名
$ext_name = strrchr($filename, "."); //取得副檔名 .jpg,請注意有包含點〝 . 〞
yoonow 發表在 痞客邦 留言(0) 人氣(2,976)
最近使用PHP5發現一個include的路徑問題。
例如,a程式include引入子目錄下的b程式,而b程式又再include引入另一個子目錄下的c程式時。
依照以往習慣的寫法,只要以a程式所在位置去設定引入b程式及c程式的相對路徑,就不會有問題。
但是在PHP5卻會出現找不到檔案的情況,解決方法就是改成以 dirname(__FILE__) 取得相對路徑。
yoonow 發表在 痞客邦 留言(0) 人氣(3,532)
一、存入資料庫前,檢查字串最後一個字元,若為反斜線〝\〞則在字串最後加上一個空白字元" "。
加在ModifyTo() if(substr($this->modified_str, -1, 1) == "\\"){
$this->modified_str .= ' ';
} class ModifyErrBig5增加 function ModifyAddSpace() function ModifyAddSpace($str){
$this->modified_str = $str;
if(substr($this->modified_str, -1, 1) == "\\"){
$this->modified_str .= ' ';
}
return $this->modified_str;
}
yoonow 發表在 痞客邦 留言(0) 人氣(406)
【資料來源:http://cgi.blog.roodo.com/trackback/2885267 】
yoonow 發表在 痞客邦 留言(0) 人氣(560)

使用 iconv 進行 UTF-8 <---> big5 或 UTF-8 <---> gb2312 轉碼時,常會因為查不到對應字集,而使輸出中斷。
使用 //IGNORE 可以忽略 iconv 轉碼錯誤,讓整段文字的輸出不會中斷。
但是有錯誤的地方會以@顯示。
◎ 範例
yoonow 發表在 痞客邦 留言(0) 人氣(12,377)
1、從Excel檔中讀出之日期格式為格林威治時間。
2、實際應用需轉換成本地時間,例如:台北時間比格林威治時間快8小時(28800秒),需減去八小時(28800秒)。¨ 範例$file_path = "../upload/txtfile/monitor_value/"; //來源檔目錄路徑
yoonow 發表在 痞客邦 留言(0) 人氣(1,477)
/* PHP mhash 模組的安裝程序 */《windows 下安裝程序》1、複製 PHP4或PHP5 套件中 dlls 目錄下已編譯好的 libmhash.dll
‧libmhash.dll 是必須用到的外掛模組。
‧將libmhash.dll複製到C:\winnt\system32。
‧若已經設定C:\PHP為環境變數,則將libmhash.dll複製到C:\PHP。
2、php.ini ,取消extension=php_mhash.dll 前面的註解。
3、執行 info.php,就可以看到已加入mcrypt模組。
yoonow 發表在 痞客邦 留言(0) 人氣(1,104)
/* PHP mcrypt 模組的安裝程序 */《windows 下安裝程序》1、下載已編譯好的 libmcrypt.dll (http://ftp.emini.dk/pub/php/win32/mcrypt/)
‧libmcrypt.dll 是必須用到的外掛模組。
‧將libmcrypt.dll複製到C:\winnt\system32。
‧若已經設定C:\PHP為環境變數,則將libmcrypt.dll複製到C:\PHP。
2、下載 libmcrypt 套件 (ftp://argeas.cs-net.gr/pub/unix/mcrypt/或http://sourceforge.net/projects/mcrypt/)
‧PHP4需使用2.4.x以上版本
‧PHP5需使用2.5.x以上版本
‧解壓縮後將資料複製到C:\PHP,更名為 mcrypt。
yoonow 發表在 痞客邦 留言(1) 人氣(13,113)
/* pear的指令 */◎、列出全部指令
pear
‧命令列視窗,輸入指令
C:>pear
-------------------------------------------------------------------------
Commands:
build 從C原始程式碼建立一個延伸 Build an Extension From C Source
bundle 解開pear套件 Unpacks a Pecl Package
clear-cache 清除XML-RPC快取 Clear XML-RPC Cache
config-get 顯示一個設定 Show One Setting
config-help 顯示設定資訊 Show Information About Setting
config-set 變更設定 Change Setting
config-show 顯示全部設定 Show All Settings
cvsdiff 對一個套件中所有檔案執行"CVS diff" Run a "cvs diff" for all files in a package
cvstag 設定套件版本標記 Set CVS Release Tag
download 下載套件 Download Package
download-all 自master_server下載全部可取得套件 Downloads each available package from master_server
info 顯示一個套件資訊 Display information about a package
install 安裝套件 Install Package
list 列出已安裝套件 List Installed Packages
list-all 列出全部套件 List All Packages
list-upgrades 列出可取得之升級項目 List Available Upgrades
login 連結遠端伺服器並取得驗證 Connects and authenticates to remote server
logout 登出遠端伺服器 Logs out from the remote server
makerpm 由pear套件建立一個RPM spec檔案 Builds an RPM spec file from a PEAR package
package 建立套件 Build Package
package-dependencies 顯示套件相依性 Show package dependencies
package-validate 驗證套件一致性 Validate Package Consistency
remote-info 遠端套件資訊 Information About Remote Packages
remote-list 列出遠端套件 List Remote Packages
run-tests 執行復原測試 Run Regression Tests
search 搜尋遠端套件資料庫 Search remote package database
shell-test Shell腳本語言測試 Shell Script Test
sign 簽入一套件版本檔案 Sign a package distribution file
uninstall 移除套件 Un-install Package
upgrade 昇級套件 Upgrade Package
upgrade-all 昇級所有套件 Upgrade All Packages
以下四行為pear基本使用方法
Usage: pear [options] command [command-options] <parameters>
Type "pear help options" to list all options.
Type "pear help shortcuts" to list all command shortcuts.
Type "pear help <command>" to get the help for the specified command.
-------------------------------------------------------------------------
yoonow 發表在 痞客邦 留言(0) 人氣(740)
/* pear的安裝程序 */《windows 下安裝程序》1、下載安裝腳本
‧http://go-pear.org/ 或是 http://pear.php.net/go-pear。
‧將會在瀏覽器畫面上看到pear的安裝腳本,另存新檔,並命名為go-pear.php。
2、安裝pear套件管理工具
‧在c:php目錄下開新目錄,命名為pear。(或是其他目錄也可以,因為pear是與php相依的套件,所以安裝到php目錄下,以方便管理)
‧將go-pear.php複製到c:phppear下。
‧執行cmd開啟命令列視窗,輸入指令
C:>c:phpphp go-pear.php
或是 C:>php go-pear.php (已設定環境變數將php路徑加入的話)
→【設定環境變數】控制台/系統/進階/環境變數
→編輯系統變數Path
→加入C:PHP;c:PHP;
‧開始連結到pear網站下載套件。
‧命令列出現提示----
-----------------------------------------------------------------------
- Welcome to go-pear!
yoonow 發表在 痞客邦 留言(0) 人氣(3,188)