One problem I see all over the place is the big question: “must I put an / in front of a path, or must I not?”
Sorry if this appears subjective, but for my framework it’s an important question:
Do you think that it’s more logical to put a “/” in front of every path when specifying one, or do you think the “/” prefix should be avoided?
Or should I check if the first char is “/” and if not, add that automatically?
Context: Framework functions that take paths.
If you put a
/in front of every path, then those paths are absolute. Without it, they are relative. Not sure what you’re after, but that’s what the/at the beginning is for.For example, if your current directory is
/var/www/html/and you give your path asfoo/bar/, the path becomes/var/www/html/foo/bar/.If you give your path as
/foo/bar/, then the path is just that, with nothing prepended.So the forward slash is just a matter of where you’re looking the files from, and if you’re using the paths as a argument to a function, you probably want to pass them as relative (to the framework directory).