面向对象风格
<?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 );
?>
前提是你的先安装php_rar扩展;