When defining a path to a directory as a variable or constant, should it end with a trailing slash? What is the convention?
pwd in Unix shows your curre
In php, since dirname(__FILE __) function returns the directory name without a slash at the end. I tend to stick to that convention.
Otherwise, using a slash at the end of a directory name will conflict with the way dirname(..) works and then you are stuck with handling the two cases since you don't know if the directory name came from a dirname(..) function or a content defined with a trailing slash.
Bottom Line: Don't use a trailing slash since dirname(..) doesn't.
// PHP Example
dirname(__FILE__); // returns c:\my\directory without a trailing slash, so stick to it!
For other languages, check the function that extracts a pathname, and see if it is using a trailing slash or not, then stick to the language's convention.