我在使用Phar访问gzipped tar文件方面遇到了麻烦。
这是我的测试代码:
<?php
function r($a) {
print " has " . count($a) . " files:\n";
foreach (new RecursiveIteratorIterator($a) as $path => $fileinfo) {
print " " . $path . "\n";
}
}
print "\n1.tgz";
r(new PharData('1.tgz'));
print "\n2.tgz";
r(new PharData('2.tgz'));
print "\norig dir:";
chdir('orig-dir');
r(new RecursiveDirectoryIterator('./'));
这里是灯具:
mkdir -p orig-dir/subdir; touch orig-dir/{a,b,subdir/c}; cd orig-dir
tar czf ../1.tgz *
tar czf ../2.tgz ./
cd ../
# put the test code file here and run with php test-code.php
这是输出:
1.tgz has 4 files:
phar:///tmp/t/1.tgz/a
phar:///tmp/t/1.tgz/b
phar:///tmp/t/1.tgz/subdir/c
2.tgz has 5 files:
orig dir: has 1 files:
./b
./.
./subdir/.
./subdir/c
./subdir/..
./..
./a
Q值。为什么phar在第二个tar文件中遇到这样的困难? (我在php 5.6上)