1. Go to this page and download the library: Download dixflatlinr/fname 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/ */
dixflatlinr / fname example snippets
use \DF\App\FName\FName;
file.ext'); # /easy/path/file.ext
$f->path('/var/www')->body('%_readme')->ext('txt'); # /var/www/file_readme.txt
//A path, no filename
$filename = '/var/www/whatever/';
$f = new FName($filename);
$this->assertEquals(['/var/www/whatever/','',''], [$f->path, $f->body, $f->ext]);
//A path's last segment without an ending slash is interpreted as a filename
$filename = '/var/www/whatever';
$f = new FName($filename);
$this->assertEquals(['/var/www/','whatever',''], [$f->path, $f->body, $f->ext]);
//Full path, with filename, without extension
$filename = '/var/www/whatever/filename';
$f = new FName($filename);
$this->assertEquals(['/var/www/whatever/','filename',''], [$f->path, $f->body, $f->ext]);
//Full path, with filename and extension
$filename = '/var/www/whatever/filename.ext';
$f = new FName($filename);
$this->assertEquals(['/var/www/whatever/','filename','ext'], [$f->path, $f->body, $f->ext]);
//double dots is a filename without extension (body only)
$filename = '..';
$f = new FName($filename);
$this->assertEquals(['','..',''], [$f->path, $f->body, $f->ext]);
//single dot is a filename without extension (body only)
$filename = '.';
$f = new FName($filename);
$this->assertEquals(['','.',''], [$f->path, $f->body, $f->ext]);
//lots of dots is still considered a filename without extension (body only)
$filename = '......';
$f = new FName($filename);
$this->assertEquals(['','......',''], [$f->path, $f->body, $f->ext]);
//lots of dots as body with an added extension - last dot is always consumed when separating the extension
$filename = '......ext';
$f = new FName($filename);
$this->assertEquals(['','.....','ext'], [$f->path, $f->body, $f->ext]);
//Multiple dots in filename
$filename = '/var/www/whatever/flying...pugs.plus.the.birds...ext';
$f = new FName($filename);
$this->assertEquals
(
['/var/www/whatever/','flying...pugs.plus.the.birds..','ext'],
[$f->path, $f->body, $f->ext]
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.