PHP code example of kohkimakimoto / temporary

1. Go to this page and download the library: Download kohkimakimoto/temporary library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kohkimakimoto / temporary example snippets


use Kohkimakimoto\Temporary\TemporaryFile;

$tmpfile = new TemporaryFile();

echo $tmpfile->path();  // ex) /private/var/folders/bt/xwh9qmcj00dctz53_rxclgtr0000gn/T/phpqWK5fj
$tmpfile->write("temporary data...");

echo $data = $tmpfile->read(); // temporary data...

// You don't need to close it. The temporary file will be closed automatically when the object removes.

use Kohkimakimoto\Temporary\TemporaryDir;

$tmpdir = new TemporaryDir();
echo $tmpdir->path();   // ex) /private/var/folders/bt/xwh9qmcj00dctz53_rxclgtr0000gn/T/KFHg4L

// You don't need to close it. The temporary dir will be deleted automatically when the object removes.