views:

58

answers:

2

I'm looking at a bit of script and I'm not sure what the "//" does.

$ResultsFolder = "./" . "Results";
$CompanyFolder = $ResultsFolder."//".$CompanyName;
+2  A: 

Doesn't do anything /./ and // mean the same thing than /

Colin Hebert
Possibly it was adapted from the windows version "\\" at some stage, which is needed to escape the backslash.
Michael Clerx
+1  A: 

Beware: it doesn't do anything in a filesystem, but it will in browsers.

Example: your script is hosted at https://dummy.tld/folder/file.php, and containing the following:

<a href="[url, see below]">Link</a>

[url] could be:

example.txt -> https://dummy.tld/folder/example.txt
/example.txt -> https://dummy.tld/example.txt
//example.txt -> https://example.txt/

Note: this behaviour applies only if it starts with '//something', if you're using './/something', it will resolve to 'something'.

Lekensteyn
In this case the path prefix is `./Results//…`.
Gumbo
This will work only if the // is at the beginning of your string ! Not the case here.
Colin Hebert
I've read over that part. Clarified in the answer.
Lekensteyn