PHP code example of fruit / pathkit

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

    

fruit / pathkit example snippets



// let's say if current working directory is /work/temp
$path = new Path('../my.file'); // path is '../my.file'
$path->isAbsolute(); // false
$path->expand(); // /work/temp/../my.file
$path->normalize(); // /work/my.file
$path->within(); // false, because /work/my.file does not belong to /work/temp
$path->within('/work'); // true
$path->relative(); // ../my.file
$path->relative('/another/work'); // ../../work/my.file