PHP's ZIP extension registers?zip:// wrapper. PHP 7.2.0 onwards supports passwords for encrypted archives. There is only one Zip context option called password
First create ZIP archive as follows:
<?php $zip = new ZipArchive; $zip->open('test.zip'); $zip->setPassword("MySecretPassword"); $zip->addFile('c:/xampp/php/test.txt', 'test.txt'); $zip->close(); >>
要從zip://流中讀取文件,請使用以下代碼
<?php $opts = array( 'zip' => array( 'password' => 'secret', ), ); $context = stream_context_create($opts); echo file_get_contents('zip://test.zip#test.txt', false, $context); ?>
以上就是PHP Zip上下文選項(xiàng)的詳細(xì)內(nèi)容,更多請關(guān)注php中文網(wǎng)其它相關(guān)文章!
PHP怎么學(xué)習(xí)?PHP怎么入門?PHP在哪學(xué)?PHP怎么學(xué)才快?不用擔(dān)心,這里為大家提供了PHP速學(xué)教程(入門到精通),有需要的小伙伴保存下載就能學(xué)習(xí)啦!
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://m.miracleart.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號