shineability
shineability

Reputation: 437

When to use $path, $dir or $file as a variable name

Obviously I know the difference between a file and a directory :) I also know that both a file and a directory have a path.

But when writing code, what will you use when?

E.g.:

I want to clear all *.js files in a directory...

$filesystem->removeJsFiles($jsDir|$jsPath);

Copy an XML file...

$filesystem->copy($xmlFile|$xmlPath);

So when will you typically use $path as a variable instead of $dir or $file (or the other way around)?

Upvotes: 3

Views: 758

Answers (1)

August Karlstrom
August Karlstrom

Reputation: 11377

If you don't need to distinguish between filenames, paths and file handles I would use simply jsDir and xmlFile. Otherwise I would use jsDirName or jsDirPath and xmlFileName or xmlFilePath, and jsDir and xmlFile for file handles.

Upvotes: 1

Related Questions