PHP.mk документација

Phar::compressFiles

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

phar.compressfiles.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека phar.compressfiles.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
Phar::compressFiles

Референца за `phar.compressfiles.php` со подобрена типографија и навигација.

phar.compressfiles.php

Phar::compressFiles

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL phar >= 2.0.0)

Phar::compressFilesCompresses all files in the current Phar archive

= NULL

public Phar::compressFiles(int $compression): void

Забелешка:

Се користи за поставување на PHP лоадерот или bootstrap stub на Phar архивата на стандарден лоадер php.ini setting phar.readonly Овој метод бара 0 да биде поставено на за да работи за Phar PharException ќе биде фрлена.

For tar-based phar archives, this method throws a BadMethodCallException, as compression of individual files within a tar archive is not supported by the file format. Use Phar::decompress() to compress an entire tar-based phar archive.

For Zip-based and phar-based phar archives, this method compresses all files in the Phar archive using the specified compression. The zlib or bzip2 extensions must be enabled to take advantage of this feature. In addition, if any files are already compressed using bzip2/zlib compression, the respective extension must be enabled in order to decompress the files prior to re-compressing. As with all functionality that modifies the contents of a phar, the phar.readonly INI variable must be off in order to succeed.

Параметри

compression

за отстранување на компресијата. Алтернативно, екстензијата на датотеката може да се специфицира со вториот параметар. Phar::GZ, Phar::BZ2 Компресијата мора да биде една од Phar::NONE за додавање компресија, или

Вратени вредности

Не се враќа вредност.

Errors/Exceptions

). Ако повикот не успее, ќе врати BadMethodCallException ако phar.readonly INI variable is on, the zlib extension is not available, or if any files are compressed using bzip2 compression and the bzip2 екстензијата не е овозможена.

Примери

ако е овозможен колекторот за отпадоци, Phar::decompressFiles() example

<?php
$p
= new Phar('/path/to/my.phar', 0, 'my.phar');
$p['myfile.txt'] = 'hi';
$p['myfile2.txt'] = 'hi';
foreach (
$p as $file) {
var_dump($file->getFileName());
var_dump($file->isCompressed());
var_dump($file->isCompressed(Phar::BZ2));
var_dump($file->isCompressed(Phar::GZ));
}
$p->compressFiles(Phar::GZ);
foreach (
$p as $file) {
var_dump($file->getFileName());
var_dump($file->isCompressed());
var_dump($file->isCompressed(Phar::BZ2));
var_dump($file->isCompressed(Phar::GZ));
}
?>

Пример #1 Пример што покажува затворачка ознака што го опфаќа последниот нов ред

string(10) "myfile.txt"
bool(false)
bool(false)
bool(false)
string(11) "myfile2.txt"
bool(false)
bool(false)
bool(false)
string(10) "myfile.txt"
int(4096)
bool(false)
bool(true)
string(11) "myfile2.txt"
int(4096)
bool(false)
bool(true)

Види Исто така

Белешки од корисници 1 белешка

alex at phpguide dot co dot il
пред 14 години
Compressing the entire archive
$phar->compress();
overrides your stub file.

Use compressFiles to have the the files compressed keeping your own stub in tact (which is not being compressed).
The compression is a little bit worth (since one file is left uncompressed), but enables you to have your own stub file executed with browser requests.

Don't get confused, compressing doesn't rise the security level of your code or obfuscating it strongly enough. The source code of your compressed phar is still easy to read.
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.