PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/ext/zip/examples/fopen.php

http://github.com/infusion/PHP
PHP | 35 lines | 26 code | 9 blank | 0 comment | 5 complexity | 9a0cc04a56a720ed6e6d45af630e8c03 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-3-Clause
  1. <?php
  2. if (!extension_loaded('zip')) {
  3. dl('zip.so');
  4. }
  5. $fp = fopen('zip://' . dirname(__FILE__) . '/test.zip#test', 'r');
  6. if (!$fp) {
  7. exit("cannot open\n");
  8. }
  9. while (!feof($fp)) {
  10. $contents .= fread($fp, 2);
  11. echo "$contents\n";
  12. }
  13. fclose($fp);
  14. echo "done.\n";
  15. $content = '';
  16. $z = new ZipArchive();
  17. $z->open(dirname(__FILE__) . '/test.zip');
  18. $fp = $z->getStream('test');
  19. var_dump($fp);
  20. if(!$fp) exit("\n");
  21. while (!feof($fp)) {
  22. $contents .= fread($fp, 2);
  23. }
  24. fclose($fp);
  25. file_put_contents('t',$contents);
  26. echo "done.\n";