1--TEST-- 2Phar: fopen a .phar for writing (new file) tar-based 3--EXTENSIONS-- 4phar 5--INI-- 6phar.readonly=0 7phar.require_hash=0 8--FILE-- 9<?php 10 11$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.tar'; 12$alias = 'phar://' . $fname; 13 14$phar = new Phar($fname); 15$phar->setStub("<?php __HALT_COMPILER(); ?>"); 16 17$files = array(); 18 19$files['a.php'] = '<?php echo "This is a\n"; ?>'; 20$files['b.php'] = '<?php echo "This is b\n"; ?>'; 21$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>'; 22 23foreach ($files as $n => $file) { 24 $phar[$n] = $file; 25} 26 27$phar->stopBuffering(); 28ini_set('phar.readonly', 1); 29 30var_dump(fopen($alias . '/b/new.php', 'wb')); 31include $alias . '/b/c.php'; 32include $alias . '/b/new.php'; 33 34?> 35 36--CLEAN-- 37<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?> 38--EXPECTF-- 39Warning: fopen(phar://%sopen_for_write_newfile_c.phar.tar/b/new.php): Failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_newfile_c.php on line %d 40bool(false) 41This is b/c 42 43Warning: include(phar://%sopen_for_write_newfile_c.phar.tar/b/new.php): Failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.tar" in %sopen_for_write_newfile_c.php on line %d 44 45Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.tar/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d 46 47