PHP code example of piyo2 / path

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

    

piyo2 / path example snippets


use piyo2\util\path\Path;

Path::join('foo', 'bar'); // => 'foo/bar'
Path::join('foo', 'bar', 'baz'); // => 'foo/bar/baz'
Path::join('/foo', 'bar'); // => '/foo/bar'
Path::join('./foo', 'bar'); // => './foo/bar'
Path::join('/foo/bar/baz', '../qux'); // => '/foo/bar/qux'

use piyo2\util\path\Path;

Path::sanitizeFileName('foo'); // => 'foo'
Path::sanitizeFileName('f/o\\o<b>a|r'); // => 'f_o_o_b_a_r'
Path::sanitizeFileName('.foo'); // => 'foo'
Path::sanitizeFileName('foo..bar'); // => 'foo__bar'

// Allow beginning dot
Path::sanitizeFileName('.foo', true); // => '.foo'