Archive_Tar::addString() – add a string in the archive


require_once 'Archive/Tar.php';

boolean addString ( string $filename , string $content )


This method adds the string content in the archive like a file with full filename filename.

If the archive does not exists it attempts to create it.


  • string $filename - the path and filename that will be associated with the added string in the archive.

  • string $content - the string to add in the archive as a file.

Return value

boolean - Returns TRUE on success, FALSE on failure.


Possible PEAR_Error values
Error code Error message Reason Solution
NULL "Unable to open in write mode file name" The file permissions for an existing file do not allow writing or the file is locked. Check permissions and possible competive programs using the file.
NULL "Unable to open file filenamein binary read mode" The file to add to the archive could not be read. Check for typing mistakes in the function argument and file permissions.


This function can not be called statically.


Add a string in a compressed archive

= new Archive_Tar("tarname.tgz");
$content "this file was generated from a string";
// A file is created in the archive with name :
//   data/readme.txt
extract one file and return it as a string (Previous) File (Next)
Last updated: Tue, 22 May 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.