PHP code example of fostam / file

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

    

fostam / file example snippets




use Fostam\File\File;

$reader = new File($filename, File::MODE_READ);

while ($line = $reader->readLine()) {
    print $line;
}

$reader->close();

$writer = new File($filename, File::MODE_WRITE_CREATE_OR_TRUNCATE);
$writer->write('test');
$writer->close();

$reader = new File($filename, File::MODE_READ);

// (read $pos from previous run)

while ($line = $reader->readLine(null, $pos)) {
    // (process $line)
    // (save $pos to resume if interrupted)
}

$reader->close();