PHP code example of icyapril / tail

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

    

icyapril / tail example snippets


$fileLocation = tempnam(sys_get_temp_dir(), 'tailTest');
file_put_contents($fileLocation, "Hello 1" . PHP_EOL . "Hello 2" . PHP_EOL . "Hello 3" . PHP_EOL);

$config = new \IcyApril\Tail\Config($fileLocation);
$config->setLines(2);

$tail = new \IcyApril\Tail\Tail($config);
echo $tail->getTail();

file_put_contents($fileLocation, "Hello 4" . PHP_EOL, FILE_APPEND | LOCK_EX);

echo $tail->getTail();
// Hello 4