Class path
Path utilities
To get started, place the following line around top of your code.
use amekusa\plz\path;
Methods summary
public static
|
#
normal( string $X, string $Separator = '/' )
Returns a normalized path
Returns a normalized path
Parameters
- $X
- Path to normalize
- $Separator
- [
'/' ] Directory separator
Example
Absolute path
echo path::normal('/srv//http/example.com///');
/srv/http/example.com/
Relative path
echo path::normal('images//favicon.svg');
images/favicon.svg
Normalize to slash
echo path::normal('xxx\yyy\zzz');
xxx/yyy/zzz
Normalize to backslash
echo path::normal('xxx/yyy/zzz', '\\');
xxx\yyy\zzz
|
public static
string
|
#
ext( string $X )
Returns the extension of a file path
Returns the extension of a file path
Parameters
Returns
string The extension of $X
Example
Demonstration
echo path::ext('choosy-developers-choose.gif');
.gif
|
public static
|
#
join( array|string* $Paths )
Returns a single path that is concatenated with supplied paths
Returns a single path that is concatenated with supplied paths
Parameters
Example
Demonstration
echo path::join('/srv', 'http/', '/example.com');
/srv/http/example.com
Passing an array
echo path::join(array ('/srv', 'http', 'example.com'));
/srv/http/example.com
|
public static
|
|