: This article mainly introduces PHP's summary of path operations. For more information about PHP tutorials, see. In PHP, there are also related functions for path operations.
1. parse_url
The information obtained by this method is the most detailed. you can obtain schme, host, path, and so on. This function is required. for detailed usage, see http://php.net/manual/en/function.parse-url.php.
2. basename
Get the basic file name of the file in the url:
For example, the content returned by basename ('www .baidu.com/hell/test/ini.php') is ini. php;
With the second parameter, you can remove the suffix in the file name:
For example, the content returned by basename ('www .baidu.com/hell/test/ini.php', '. php') is ini;
Note:
For example, after basename ('www .baidu.com/hell/test/') passes through this function, test is returned;
Detailed reference http://php.net/manual/zh/function.basename.php
3. dirname
Get the path name of the file in the url:
Dirname ('www .baidu.com/hell/test/ini.php') returns www.baidu.com/hell/test
4. pathInfo
Get the dirname and basename content directly.
5. explode
Split string
6. substr
Substring
7. join
Concatenate strings in the array
8. implode
Convert the array into a string. you can also say that the connected string is the alias of join. the two functions are the same.