Sunday, January 27, 2013

The Path's Dirname, Basename and Extension

One of the important thing to know if you are a web developer is the information of a path of a file. If you're in studying of server-side programming language, such as PHP: Hypertext Preprocessor, also simplified as just PHP, you may saw some filesystem functions like dirname() function which is used to returns the directory name, and basename() function used to returns the file name, from a path. And frequently seen suffixes of web addresses or URLs of static websites such .html and .php are called as an extension.
For example, we have a Uniform Resource Locator (also known as simply as URL,) of this blog post as I mentioned above and its details are listed below:
  1. First of all, the first thing you should know is the path name on the web address of this web page. A path is the general form of the name combining a file and directory, and it's simply as all the text in bold on the URL that I've written above, as /2013/01/the-paths-dirname-basename-and-extension.html and remember that all of the names after the name of a domain name such before another slash [/] is a path name.
  2. The dirname is highlighted with the color orange, /2013/01 but remember if the sub directory "/01" did not exist, the directory will just become /2013 and if the home page of a web site doesn't have a path but just a slash, [/] such as or just a file name such as these URLs doesn't have a dirname but just a directory of a slash as exact as / (forward slash).
  3. The basename is a filename of the URL and the URL's basename of this page is highlighted, likewise, with the color yellow, the-paths-dirname-basename-and-extension.html and now if the URL didn't have a basename, the file name of it is just not visible as nothing! But the truth is all web pages has their own file names. Most file names if named as index.html or index with some other extension, such as can be access without its filename such as it!
  4. The extension is seen as the suffix of the name of a URL and even of any computer file which designed to show the format of a file, such as .html if it's in the format of Hyper-Text Markup Language, .xml if it's formatted in eXtensible Markup Language, etc... So, the extension of this page's URL is the color blue .html but in web development, most extension wasn't really show the exact format of a file, such as a PHP file which can be written with other web development languages, such as HTML and can have an .html or .php extension.
Remember that the path name of a Uniform Resource Locator has three different kinds of names, the dirname which is the abbreviation for the word "directory name", the basename that acting as exactly as file name, and the extension which designed to show the format of a file but not all types of scripts in web development can be shown by an extension.

No comments:

Post a Comment

You can use some HTML tags, such as <b>, <i> and <a> tags, but please do not spam.