PHP code example of emmetog / temporary

1. Go to this page and download the library: Download emmetog/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/ */

    

emmetog / temporary example snippets




use Emmetog\Temporary\File;

$tempFile = new File();

// Returns the generated temporary filename.
$filename = $tempFile->getFilename();

file_put_contents($filename, 'This file is only temporary');

// When we remove all references to the object, the file is removed.
unset($tempFile);
// Or
$tempFile->remove();



use Emmetog\Temporary\Directory;

$tempDir = new Directory();

// Returns the generated temporary directory path.
$tempPath = $tempDir->getDirectory();

// Let's fill the directory with a file.
file_put_contents($tempPath . '/somefile.txt', 'This file is inside a temporary dir');

// When we remove all references to the object, the directory and
// all subdirectories are removed.
unset($tempDir);
// Or
$tempDir->remove();