Describes how to use the php function to retrieve the file name basename,
In PHP, The basename () function provides a string containing a full path to a file. This function returns the basic file name. This article collects information about the use of PHP basename () this article describes how to use a function to obtain a file name.
1. Explain how to get the file name using the php basename () function
The php basename () function provides a string containing the full path to a file. This function returns the basic file name. If the file name ends with suffix, this part will also be removed. In Windows, slash (/)
And backslash (\) can be used as Directory separator. Slash (/) in other environments (/)
2. Analysis of _ FILE _, dirname, and basename usage examples in PHP
This article uses examples to describe the usage of _ FILE _, dirname, and basename in PHP. Share it with you for your reference. The specific method is as follows: in php, the complete path and FILE name of the current running FILE are _ FILE _. If the FILE is used in the included FILE, the included FILE name is returned, this is a magic variable (a predefined constant). We can use dirname and basename to obtain the file directory or file name.
3. Use the php pathinfo (), parse_url (), basename () function to parse the URL instance.
PHP functions pathinfo (), parse_url (), and basename () are all URL-Resolved functions, but there are also some differences. This article lists some examples, we hope that these instances will help you better understand the usage methods and skills of these three functions,The pathinfo function is used to obtain the path, directory, or file name of a file. The parse_url () function is used to parse the URL and return an associated array of the resolution components. This function does not check whether the URL is legal, but only resolves the URL correctly. Name of the file in the returned path of the basename () function
4. Differences between dirname, basename, and pathinfo functions and examples in php
The php dirname function is used to obtain the directory part of the given file path. The php basename () function gets the file name part of the path, which is exactly the opposite of dirname () (dirname gets the directory part of the path ). The php pathinfo function is used to parse the path and parse the path into an array. The array includes four values: directory name, complete file name, file extension, and file name (excluding file suffix, the key names of these four values are dirname, basename, extension, and filename. We can use these four key names to obtain the directory name, complete file name, file extension, and file name value. This article mainly introduces the differences between the three functions and the use cases.
[Q & A about the basename () function]
Php basename gets the file name. If it is a special symbol, it will contain garbled characters!
[Basename entry]
Basename
[Recommended related articles]
Php pathinfo () function get file path information usage Summary
Php dirname () function returns the file directory usage Summary
The above is a summary of the usage of the php function for obtaining the file name basename (). For more information, see other related articles on php Chinese network!