Home / PHP Tips Generated By ChatGPT / Handling File Paths and Directories in PHP Use built-in functions to manipulate and retrieve file path components. Source Code echo basename('/path/to/myfile.txt'); // Outputs: myfile.txt echo dirname('/path/to/myfile.txt'); // Outputs: /path/to