Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当tar内容具有相对路径时,PharData类失败_Php_Phar - Fatal编程技术网

Php 当tar内容具有相对路径时,PharData类失败

Php 当tar内容具有相对路径时,PharData类失败,php,phar,Php,Phar,我在使用Phar访问Gzip 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

我在使用Phar访问Gzip 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('./'));
以下是输出:

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

问:为什么phar在处理第二个tar文件时遇到如此困难?(我使用的是PHP5.6)

很抱歉,您遇到了这些问题。。。我也是。看起来我可能无法将
PharData
用于我的特定用例:(
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