Phar::addFile
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
Phar::addFile
Референца за `phar.addfile.php` со подобрена типографија и навигација.
Phar::addFile
(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL phar >= 2.0.0)
Phar::addFile — Add a file from the filesystem to the phar archive
= NULL
Забелешка:
Се користи за поставување на PHP лоадерот или bootstrap stub на Phar архивата на стандарден лоадер php.ini setting
phar.readonlyОвој метод бара0да биде поставено на за да работи за Phar PharException ќе биде фрлена.
With this method, any file or URL can be added to the phar archive. If the optional second parameter localName е string, the file will be stored in the archive with that name, otherwise the
file parameter is used as the path to store within the archive. URLs must have a localname or an exception is thrown. This method is similar to (PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL zip >= 1.9.0).
Параметри
filename-
Full or relative path to a file on disk to be added to the phar archive.
localName-
Path that the file will be stored in the archive.
Вратени вредности
no return value, exception is thrown on failure.
Дневник на промени
| Верзија | = NULL |
|---|---|
| 8.0.0 |
localName сега е null.
|
Примери
ако е овозможен колекторот за отпадоци, Phar::addFile() example
<?php
try {
$a = new Phar('/path/to/phar.phar');
$a->addFile('/full/path/to/file');
// demonstrates how this file is stored
$b = $a['full/path/to/file']->getContent();
$a->addFile('/full/path/to/file', 'my/file.txt');
$c = $a['my/file.txt']->getContent();
// demonstrate URL usage
$a->addFile('http://www.example.com', 'example.html');
} catch (Exception $e) {
// handle errors here
}
?>Белешки
Забелешка: Phar::addFile(), Phar::addFromString() and Phar::offsetSet() save a new phar archive each time they are called. If performance is a concern, Phar::buildFromDirectory() or Phar::buildFromIterator() треба да се користи наместо тоа.
Види Исто така
- Phar::offsetSet() - Постави ги содржините на внатрешна датотека на оние од надворешна датотека
- PharData::addFile() - Додава празна директориум во tar/zip архивата
- Phar::addFromString() - Додава датотека од стринг во phar архивата
- Phar::addEmptyDir() - Додава празна директориум во phar архивата