本文整理汇总了PHP中tar::containsFile方法的典型用法代码示例。如果您正苦于以下问题:PHP tar::containsFile方法的具体用法?PHP tar::containsFile怎么用?PHP tar::containsFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tar
的用法示例。
在下文中一共展示了tar::containsFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
} else {
echo " There are no directories described in this tar archive.<br>\n";
}
echo "<br>\n";
// List files in the currently opened tar file(s)
echo "<b>Files in " . $tar->filename . "</b><br>\n";
if ($tar->numFiles > 0) {
foreach ($tar->files as $id => $information) {
echo " {$information['directory']}/{$information['name']}<br>\n";
}
} else {
echo " There are no files described in this tar archive.<br>\n";
}
echo "<br>\n";
// Check if a file exists in the tar file
if ($tar->containsFile("fake.php")) {
echo "<b>This TAR Archive does contain a file called fake.php!</b><br>\n";
} else {
echo "<b>This TAR Archive does not contain any files called fake.php!</b><br>\n";
}
echo "<br>\n";
// Add a file to the archive
if ($tar->addFile("example.php")) {
echo "Added 'example.php' to archive!<br>\n";
} else {
echo "Could not add 'example.php' to archive!<br>\n";
}
echo "<br>\n";
// Save changes to a NEW tar file
if (!$tar->toTar("test.tgz", TRUE)) {
echo "Could not save Gzipped TAR Archive!<br>\n";
示例2: tar
$tar->openTAR("my.tar", FALSE);
$tar->appendTar("another.tar", FALSE);
$tar->toTar("combined.tgz", TRUE);
unset($tar);
// Removing 2 files from the new.tar file created above
$tar = new tar();
$tar->openTar("new.tar", FALSE);
$tar->removeFile("example.php");
$tar->removeFile("example2.php");
$tar->saveTar();
// Saves to currently open TAR file (In this case, new.tar)
unset($tar);
// Check if a TAR file contains a specific file
$tar = new tar();
$tar->openTar("new.tar", FALSE);
if ($tar->containsFile("tar.class.php")) {
echo "This tar file contains a file named 'tar.class.php'!<br>\n";
} else {
echo "This tar file does NOT contain a file named 'tar.class.php'!<br>\n";
}
// There is no need to save our tar file since we did not edit it, so delete our tar class
unset($tar);
// Get information about a file in a TAR file
$tar = new tar();
$tar->openTar("new.tar");
// If second argument is not present, default is FALSE
$information = $tar->getFile("tar.class.php");
echo "<br>\n<b>Information about tar.class.php!</b><br>\n";
foreach ($information as $key => $value) {
echo " {$key} = " . text2html($value) . "<br>\n";
}