本文整理汇总了PHP中Archive::unpack方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive::unpack方法的具体用法?PHP Archive::unpack怎么用?PHP Archive::unpack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Archive
的用法示例。
在下文中一共展示了Archive::unpack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPackUnpackTar
/**
* @param string $destinationFile
* @param string $extensionRequired
* @dataProvider tarProvider
*/
public function testPackUnpackTar($destinationFile, $extensionRequired)
{
if ($extensionRequired && !extension_loaded($extensionRequired)) {
$this->markTestSkipped("The extension '{$extensionRequired}' is not enabled.");
}
$this->packed = $this->archive->pack($this->sourceFilePath, $this->destinationDir . $destinationFile);
$this->assertFileExists($this->packed);
$this->assertEquals($this->destinationDir . $destinationFile, $this->packed);
$unpacked = $this->archive->unpack($this->packed, $this->destinationDir);
$this->unpacked = $unpacked . pathinfo($this->sourceFilePath, PATHINFO_BASENAME);
$this->assertFileExists($this->unpacked);
$this->assertStringStartsWith($this->destinationDir, $this->unpacked);
}
示例2:
$dirOut = __DIR__ . DIRECTORY_SEPARATOR . 'out';
$fileArchive = __DIR__ . DIRECTORY_SEPARATOR . 'archive';
?>
<!DOCTYPE html>
<html lang="ru">
<head><meta charset="utf-8"></head>
<body>
<?php
if (Archive::pack($dirIn, $fileArchive)) {
?>
Создан архив <b><?php
echo $fileArchive;
?>
<br/></b>
<?php
}
?>
<?php
if (Archive::unpack($dirOut, $fileArchive)) {
?>
И успешно распакован в директорию <b><?php
echo $dirOut;
?>
</b>
<?php
}
?>
</body>
</html>