php读取rar压缩包文件信息

发布于 2021-04-17 21:28:22

php如何读取和解压rar格式的压缩包?

查看更多

浏览量
2843
1 个回答
猫哥
猫哥 项目组成员 2021-04-17
希望我的回答能对你有所帮助

面向对象风格

<?php
$rar_arch  =  RarArchive :: open ( 'solid.rar' );
if ( $rar_arch  ===  FALSE )
    die( "Could not open RAR archive." );

$rar_entries  =  $rar_arch -> getEntries ();
if ( $rar_entries  ===  FALSE )
    die( "Could retrieve entries." );

echo  "Found "  .  count ( $rar_entries ) .  " entries.\n" ;

foreach ( $rar_entries  as  $e ) {
    echo  $e ;
    echo  "\n" ;
}
$rar_arch -> close ();
?>

过程化风格

<?php
$rar_arch  =  rar_open ( 'solid.rar' );
if ( $rar_arch  ===  FALSE )
    die( "Could not open RAR archive." );

$rar_entries  =  rar_list ( $rar_arch );
if ( $rar_entries  ===  FALSE )
    die( "Could retrieve entries." );

echo  "Found "  .  count ( $rar_entries ) .  " entries.\n" ;

foreach ( $rar_entries  as  $e ) {
    echo  $e ;
    echo  "\n" ;
}
rar_close ( $rar_arch );
?>

学习
记录

发布
问题

分享
好友

手机
浏览

扫码手机浏览