Home > Backend Development > PHP Tutorial > PHP Phar context options

PHP Phar context options

WBOY
Release: 2023-08-19 20:38:02
forward
1029 people have browsed it

PHP Phar 上下文选项

Introduction

Phar stands for PHP Archive. All resources for a PHP application or library are packaged in a single .phar file for distribution. phar files are available as IO streams with the phar:// wrapper. The context options for the phar:// wrapper are as follows:

compress

PHP has the following predefined constants to define the compression format

##Phar::NONE 0x00000000No compressionPhar::COMPRESSED0x0000F000Bit mask and file flags , used to determine if there is any compression Phar::GZ0x00001000zlib (gzip) compressionPhar::BZ20x00002000bzip2 compression
Constant Value Description

metadata

Any phar archive containing description PHP variables with information are available as arguments to the

Phar::setMetadata() method

Example

This example sets the Phar context options used to create Phar files

<?php
$context = stream_context_create(array(&#39;phar&#39; =>
array(&#39;compress&#39; => Phar::GZ)),
array(&#39;metadata&#39; => array(&#39;user&#39; => &#39;cellog&#39;)));
file_put_contents(&#39;phar://my.phar/somefile.php&#39;, 0, $context);
?>
Copy after login

The above is the detailed content of PHP Phar context options. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template