Home > Backend Development > PHP Tutorial > Summary of path operations in PHP

Summary of path operations in PHP

WBOY
Release: 2016-08-08 09:25:42
Original
879 people have browsed it

In PHP, there are also related functions for path operations.
1. parse_url
This method obtains the most detailed information, including schme, host, path, etc. This function must be known. Detailed usage can be found at http://php.net/manual/en/function.parse-url.php.
2. basename
Get the base filename of the file in url:
For example, basename(‘www.baidu.com/hell/test/ini.php’) returns ini.php;
With the second parameter, you can remove the suffix in the file name:
For example, basename(‘www.baidu.com/hell/test/ini.php’, ‘.php’) returns ini;
Also worth noting:
For example, after basename(‘www.baidu.com/hell/test/’) passes through this function, it returns test;
For specific details, please refer to 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
Directly obtain the contents of dirname and basename
5. explode
Split string
6. substr
Get substring
7. join
Concatenate strings in array
8. implode
Turning an array into a string, or concatenating strings, is an alias for join. The two functions are the same.

The above has introduced a summary of the operation of paths in PHP, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template