手机
当前位置:查字典教程网 >编程开发 >php教程 >php安装php_rar扩展实现rar文件读取和解压的方法
php安装php_rar扩展实现rar文件读取和解压的方法
摘要:本文实例讲述了php安装php_rar扩展实现rar文件读取和解压的方法。分享给大家供大家参考,具体如下:PHPRarArchiving模块...

本文实例讲述了php安装php_rar扩展实现rar文件读取和解压的方法。分享给大家供大家参考,具体如下:

PHP Rar Archiving 模块 (php_rar) 是一个读取和解压rar文件的模块,但不提供RAR压缩(打包)的功能。

1.首先要到PECL的RAR页面下载DLL. 根据自己的情况选择下载对应版本的DLL.

PHP版本要求:php_rar模块适用于php 5.2及以上, 不过对于windows系统,似乎只有php5.3 / 5.4对应的DLL下载。

2.下载到的是个zip包,将其中的php_rar.pdb和php_rar.dll两个文件解压到PHP安装目录下的ext子目录中。

3.在php.ini中加入一行php_rar扩展引用声明 extension=php_rar.dll

4.如果使用Apache服务器,就需要重启Apache。IIS下以FastCGI模式加载的PHP则不需要进一步操作了。

5.写个测试文件看看有没有问题啊

6.如果有问题,查看服务器的日志文件。

附官方的测试代码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); ?>

希望本文所述对大家PHP程序设计有所帮助。

【php安装php_rar扩展实现rar文件读取和解压的方法】相关文章:

php中smarty实现多模版网站的方法

Yii实现自动加载类地图的方法

php简单实现屏蔽指定ip段用户的访问

php使用post数组的键值创建同名变量并赋值的方法

php使用array_search函数实现数组查找的方法

php从文件夹随机读取文件的方法

php实现读取和写入tab分割的文件

php中smarty区域循环的方法

php简单实现多字节字符串翻转的方法

php实现TCP端口检测的方法

精品推荐
分类导航