Archive_Tar::create() – create archive file


require_once 'Archive/Tar.php';

boolean create ( mixed $filelist )


This method creates the archive file and adds the listed files or directories.

If a file with the same tar name exists and is writable, it is replaced by the new tar archive (it is not an 'add', but a 'create'). If a file exists and is write-protected or is a folder, the method raises a PEAR_Error.


  • mixed $filelist - an array of filenames and directory names, or a single string with names separated by a single blank space. For each directory added in the archive, the files and sub-directories are also added.

Return value

boolean - Returns TRUE on success, FALSE on failure.


Possible PEAR_Error values
Error code Error message Reason Solution
NULL "Invalid file list" The argument for the function is not correct formatted or build. Check for typing mistakes in the argument


This function can not be called statically.


Creating an archive

= new Archive_Tar("myArchive.tar");

// print errors

// Archive content
// the slash is optional

// create the archive

Creating a compressed archive, use a string as create() argument

= new Archive_Tar("tarname.tgz"true);
$tar_object->create("file.txt data/ file.log");
add files or directories (Previous) create a new archive (Next)
Last updated: Tue, 19 Jun 2018 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.