相關(guān)關(guān)鍵詞
關(guān)于我們
最新文章
- PHP中opcode緩存簡(jiǎn)單用法分析
- thinkPHP控制器變量在模板中的顯示方法示例
- PHP move_uploaded_file() 函數(shù)(將上傳的文件移動(dòng)到新位置)
- dirname(__FILE__)的含義和應(yīng)用說(shuō)明
- thinkPHP5框架實(shí)現(xiàn)分頁(yè)查詢功能的方法示例
- PHP中單雙號(hào)與變量
- PHP獲得當(dāng)日零點(diǎn)時(shí)間戳的方法分析
- Laravel ORM對(duì)Model::find方法進(jìn)行緩存示例詳解
- PHP讀寫(xiě)文件高并發(fā)處理操作實(shí)例詳解
- 【CLI】利用Curl下載文件實(shí)時(shí)進(jìn)度條顯示的實(shí)現(xiàn)
php安裝php_rar擴(kuò)展實(shí)現(xiàn)rar文件讀取和解壓的方法
本文實(shí)例講述了php安裝php_rar擴(kuò)展實(shí)現(xiàn)rar文件讀取和解壓的方法。分享給大家供大家參考,具體如下:
PHP Rar Archiving 模塊 (php_rar) 是一個(gè)讀取和解壓rar文件的模塊,但不提供RAR壓縮(打包)的功能。
1.首先要到PECL的RAR頁(yè)面下載DLL. 根據(jù)自己的情況選擇下載對(duì)應(yīng)版本的DLL.
PHP版本要求:php_rar模塊適用于php 5.2及以上, 不過(guò)對(duì)于windows系統(tǒng),似乎只有php5.3 / 5.4對(duì)應(yīng)的DLL下載。
2.下載到的是個(gè)zip包,將其中的php_rar.pdb和php_rar.dll兩個(gè)文件解壓到PHP安裝目錄下的ext子目錄中。
3.在php.ini中加入一行php_rar擴(kuò)展引用聲明 extension=php_rar.dll
4.如果使用Apache服務(wù)器,就需要重啟Apache。IIS下以FastCGI模式加載的PHP則不需要進(jìn)一步操作了。
5.寫(xiě)個(gè)測(cè)試文件看看有沒(méi)有問(wèn)題啊
6.如果有問(wèn)題,查看服務(wù)器的日志文件。
附官方的測(cè)試代碼test-rar.php :
<?php $archive_name = '/full/path/to/file.rar' $entry_name = 'path/to/archive/entry.txt'; //notice: no slash at the beginning $dir_to_extract_to = '/path/to/extract/dir'; $new_entry_name = 'some.txt'; $rar = rar_open($archive_name) OR die('failed to open ' . $archive_name); $entry = rar_entry_get($rar, $entry_name) OR die('failed to find ' . $entry_name . ' in ' . $archive_name); // this will create all necessary subdirs under $dir_to_extract_to $entry->extract($dir_to_extract_to); /* OR */ // this will create only one new file $new_entry_name in $dir_to_extract_to $entry->extract('', $dir_to_extract_to.'/'.$new_entry_name); // this line is really not necessary rar_close($rar); ?>