《PHP應用:php安裝php_rar擴展實現rar文件讀取和解壓的方法》要點:
本文介紹了PHP應用:php安裝php_rar擴展實現rar文件讀取和解壓的方法,希望對您有用。如果有疑問,可以聯系我們。
PHP教程本文實例講述了php安裝php_rar擴展實現rar文件讀取和解壓的方法.分享給大家供大家參考,具體如下:
PHP教程PHP Rar Archiving 模塊 (php_rar) 是一個讀取和解壓rar文件的模塊,但不提供RAR壓縮(打包)的功能.
PHP教程1.首先要到PECL的RAR頁面下載DLL. 根據自己的情況選擇下載對應版本的DLL.
PHP教程PHP版本要求:php_rar模塊適用于php 5.2及以上, 不過對于windows系統,似乎只有php5.3 / 5.4對應的DLL下載.
PHP教程2.下載到的是個zip包,將其中的php_rar.pdb和php_rar.dll兩個文件解壓到PHP安裝目錄下的ext子目錄中.
PHP教程3.在php.ini中加入一行php_rar擴展引用聲明 extension=php_rar.dll
PHP教程4.如果使用Apache服務器,就需要重啟Apache.IIS下以FastCGI模式加載的PHP則不需要進一步操作了.
PHP教程5.寫個測試文件看看有沒有問題啊
PHP教程6.如果有問題,查看服務器的日志文件.
PHP教程附官方的測試代碼test-rar.php :
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);
?>
PHP教程更多關于PHP相關內容感興趣的讀者可查看本站專題:《PHP擴展開發教程》、《php文件操作總結》、《PHP目錄操作技巧匯總》、《PHP常用遍歷算法與技巧總結》、《PHP數組(Array)操作技巧大全》、《PHP基本語法入門教程》、《PHP運算與運算符用法總結》、《php字符串(string)用法總結》及《php常見數據庫操作技巧匯總》
PHP教程希望本文所述對大家PHP程序設計有所幫助.
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/2749.html