/**
* Get the trailing name component from a file path.
*
* @return string The trailing name of a given file.
*/
public function basename(): string
Examples
$result = $filesystem->file('/foo/1.txt')->basename();
echo $result;
The above example will output:
1.txt
Getting Started
Methods
Filesystem
- directory Create a Directory instance.
- file Create a File instance.
- find Create a File instance.
- glob Find path names matching a given pattern.
- isAbsolute Determine if the given path is absolute path.
- isStream Determine if the given path is a stream path.
- isWindowsPath Determine if the given path is absolute path.
File
- append Append to a file.
- basename Get the trailing name component from a file path.
- chmod Get/Set UNIX mode of a file.
- copy Copy a file to a new location.
- delete Delete the file at a given path.
- exists Checks the existence of file and returns false if any of them is missing.
- extension Get the file extension from a file path.
- get Get the contents of a file.
- hash Get the MD5 hash of the file at the given path.
- isFile Determine if the given path is a regular file.
- isReadable Determine if the given path is readable.
- isWritable Determine if the given path is writable.
- lastAccess Get the file's last access time.
- lastModified Get the file's last modification time.
- mimeType Get the mime-type of a given file.
- move Move a file to a new location.
- name Get the file name from a file path.
- path Return current path.
- prepend Prepend to a file.
- put Write the contents of a file.
- sharedGet Get contents of a file with shared access.
- size Gets file size in bytes.
- type Get the file type of a given file.
Directory
- chmod Get/Set UNIX mode of a directory.
- clean Empty the specified directory of all files and directories.
- copy Copy a directory from one location to another.
- create Create a directory.
- delete Delete a directory.
- exists Checks the existence of directory and returns false if any of them is missing.
- isDirectory Determine if the given path is a directory.
- move Move a directory.
- path Return current path.
- size Gets size of a given directory in bytes.