1<?php
2
3$fname = dirname(__FILE__) . '/write5.phar';
4@unlink($fname);
5
6$phar = new Phar($fname);
7$phar->setStub('<?php
8$phar = new Phar(__FILE__);
9$d = dirname(__FILE__) . "/copyonwrite5";
10mkdir($d);
11file_put_contents($d . "/file1", "file1\n");
12file_put_contents($d . "/file2", "file2\n");
13$arr = $phar->buildFromDirectory($d);
14ksort($arr);
15var_dump($arr);
16$phar2 = new Phar(__FILE__);
17$arr = array();
18foreach ($phar2 as $name => $file) {
19    $arr[$name] = $file->getContent();
20}
21ksort($arr);
22foreach ($arr as $name => $content) {
23    echo $name, " ", $content;
24}
25echo "ok\n";
26__HALT_COMPILER();
27?>');
28$phar['hi'] = "hi\n";
29?>
30