Home  >  Article  >  Backend Development  >  PHP Phar context options

PHP Phar context options

WBOY
WBOYforward
2023-08-19 20:37:05997browse

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);
?>

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

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete