php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #22399 file_exists : example given of shared path format is obviously defective
Submitted: 2003-02-24 12:42 UTC Modified: 2003-03-03 11:41 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: alan at frostick dot com Assigned: victor (profile)
Status: Closed Package: Documentation problem
PHP Version: 4.3.1 OS: WIN32
Private report: No CVE-ID: None
 [2003-02-24 12:42 UTC] alan at frostick dot com
Manual\function.file-exists.html
Error in manual page?

"On windows, use //computername/share/filename or \\\\computername\share\filename"

Obviously wrong - shouldn't that read:

"On windows, use //computername/share/filename or \\\\computername\\share\\filename"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-24 17:55 UTC] php at mijav dot dk
I partially agree. I agree that it's incorrect. But the correct way should be '\\computername\share\filename' in plings, or "\\\\computername\\share\\filename" in quotes, as you said.
I don't think the manual should read \\\\ (escaped backslashes) unless it is writtenly-quoted, to avoid misunderstanding.
 [2003-02-25 16:27 UTC] stone@php.net
At least "//server/share/filename/" had been working starting from 4.1.0 while '\\server\share\filename' didn't for quite a long time (until 4.2.0?). 
If you want to write cross plattform code it's not a bad idea to rely on php's auto conversion of slashes to backslashes in file paths on windows platforms.
 [2003-02-25 16:29 UTC] stone@php.net
Sorry, I changed submitter's e-mail.
 [2003-03-02 04:48 UTC] victor@php.net
I've changed \\\\computername\share\filename to \\computername\share\filename and put every example in single quotes to make it more even more clear. 
 [2003-03-02 17:49 UTC] edink@php.net
Wrong! You need to escape backslash character in any type of php string, including string in single quotes. So the correct way to write it would be:

'\\\\computername\\share\\filename'
 [2003-03-03 02:02 UTC] victor@php.net
Well, ...

You _are_ right that I _should_ do that, but you actually only have to escape backslashes in a single quote when they are at the end of the string (or escaping single quotes in a single quoted string). So there is actually no errors in my example. ref: http://www.php.net/manual/en/language.types.string.php

What I think is best is to write \\computername\share\filename without the quotes and hope that the user is intelligent enought to understand that the path has to be escaped properly when put inside double quotes. Any other suggestions?
 [2003-03-03 11:41 UTC] victor@php.net
*bonk*. No, as edin told me by mail, I was incorrect. Anyway: It's fixed in CVS now (I simply removed all single quotes). Case closed. (?)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 17 16:01:28 2024 UTC