2 Phar: fopen a .phar for writing (existing file) zip-based
4 <?php if (!extension_loaded("phar")) die("skip"); ?>
5 <?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
12 $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
13 $alias = 'phar://' . $fname;
15 $phar = new Phar($fname);
16 $phar->setStub('<?php __HALT_COMPILER(); ?>');
20 $files['a.php'] = '<?php echo "This is a\n"; ?>';
21 $files['b.php'] = '<?php echo "This is b\n"; ?>';
22 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
24 foreach ($files as $n => $file) {
27 $phar->stopBuffering();
29 ini_set('phar.readonly', 1);
31 $fp = fopen($alias . '/b/c.php', 'wb');
34 include $alias . '/b/c.php';
38 <?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
41 Warning: fopen(phar://%sopen_for_write_existing_c_5_2.phar.zip/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_c_5_2.php on line %d
43 Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c_5_2.php on line %d
45 Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c_5_2.php on line %d