RE: [PHP-WIN] problem to open dir
| From: | Gryffyn, Trevor | Date: | Tue, 30 Nov 2004 14:55:17 +0000 |
| Subject: | RE: [PHP-WIN] problem to open dir | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-25084@lists.php.net to get a copy of this message | ||
Good call.. With the ~1 and all. Using short filenames/paths might help
sometime (when things have an issue with spaces in filenames).
To get short filenames and paths, use the "dir /x" command at a command
prompt.
Also.. Regarding the \ only sometimes giving issues... It'll only give
you a problem if it's followed by a letter or character that can be
escaped. The ones I can remember off the top of my head would be \" \t
\r \n and \' maybe.
Basically anything that the following functions fix for you:
Quotemeta()
Addslashes()
magic_quotes_gpc = On (in PHP.INI)
I see some others mentioned in Pattern Syntax for regular expressions
that I think are valid too:
http://www.php.net/manual/en/reference.pcre.pattern.syntax.php
And probably some other stuff I forgot (or just don't know).
I've used single backslashes for static file paths before and they
worked ok, then I added an extra path that happened to have something
like "C:\test" or something and the \t threw it off. So I just do \\
when I do file paths now... Just seems safer and less headache. Ugly
but safer.
-TG
> -----Original Message-----
> From: Armando [mailto:dijital@shaw.ca]
> Sent: Tuesday, November 30, 2004 12:58 AM
> To: php-windows@lists.php.net
> Subject: RE: [PHP-WIN] problem to open dir
>
>
> Try changing your $dir variable to:
>
> $dir="C:\\Documents and Settings\\pravin\\Desktop\\abcd2";
>
> Failing that, try using the Documents and Settings shortname:
>
> $dir="C:\Docume~1\pravin\Desktop\abcd2";
>
> Or:
>
> $dir="C:\\Docume~1\\pravin\\Desktop\\abcd2";
>
> If none of these work, perhaps also try them and replace the double
> quotes that enclose the string to single quotes.
>
> I ran into a lot of issues myself when trying to access the windows
> filesystem through PHP when using just single backslashes in my path
> variables because, as Mike noted, the \ is typically used to escape
> characters. In that case when PHP parses your $dir variable,
> it could be
> stripping out the \ thinking they are escaping the next characters. As
> soon as I used the double backslashes in my $dir variables on my own
> pages, everything worked fine. Mind you, I then got annoyed with some
> other Windows related issues so blew away my development box and put
> Linux on it instead :-) But I digress...
>
> Cheers.
>
> Armando