PHP basename () function gives a string containing a full path to a file, this function returns the basic file name, this article collected about the use of PHP basename () function to get the file name of a few articles, I hope to understand that you use PHP basename () function to get the filename is helpful.
1. The PHP basename () function Gets the use of the file name
The PHP basename () function gives a string containing a full path to a file, which returns the basic file name. If the file name ends in suffix, then this part will be removed as well. In Windows, slash (/)
and backslashes (\) can be used as directory separators. Slash (/) in other environments
Example analysis of __file__, dirname and basename usages in 2.PHP
This article uses examples to describe __file__, dirname, and basename usages in PHP. Share to everyone for your reference. The method is as follows: __file__ the full path and file name of the current running file in PHP, and if used in the included file, returns the included file name, which is a magic variable (predefined constant), we can get the file directory or filename by Universal dirname and basename.
3. Use PHP pathinfo (), Parse_url (), basename () function to parse the URL instance explained
PHP functions PathInfo (), Parse_url (), and basename (), these three are all functions that parse the URL, but there are some differences, this article lists some examples, hope that through these examples to help you understand the three functions of the use of methods and techniques, The PathInfo function is the path, directory, or file name that gets the file. The Parse_url () function is used to parse the URL and return an associative array of parsing components, which does not detect whether the URL is legitimate and only resolves it as correctly as possible. The basename () function returns the file name in the path
The difference and example of dirname,basename,pathinfo function in 4.php
The PHP dirname function is to get the directory portion of a given file path, and the PHP basename () function gets the file name portion of the path, which is exactly the opposite of DirName () (DirName gets the directory portion of the path). The PHP pathinfo function parses the path and resolves the path to an array of four values, including the directory name, the full filename, the file extension, and the file name (not including the file suffix), and the key names for the four values are dirname, basename, Extension and filename, we can get the value of the directory name, the full filename, the file extension, and the file name through the four key names. This article mainly introduces to you the difference of these three functions and the usage examples.
"Questions and Answers about the basename () function"
PHP basename get filenames, special symbols will be garbled!
"BaseName Entry"
BaseName
"Related articles recommended"
PHP pathinfo () function get file path Information Usage Summary
PHP dirname () function return file directory Usage Summary