Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> PHP

PHP Zip context options

Giới thiệu

Phần mở rộng ZIP của PHP đăng ký wrapper zip://. Từ PHP 7.2.0 hỗ trợ mật khẩu cho kho mã hóa. Chỉ có một tùy chọn ngữ cảnh Zip là password.

Ví dụ

Tạo kho ZIP:

<?php $zip = new ZipArchive; $zip->open('test.zip'); $zip->setPassword("MySecretPassword"); $zip->addFile('c:/xampp/php/test.txt', 'test.txt'); $zip->close(); >>

Đọc file từ zip:// stream:

<?php $opts = array( 'zip' => array( 'password' => 'secret', ), ); $context = stream_context_create($opts); echo file_get_contents('zip://test.zip#test.txt', false, $context); ?>