Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199903

[PHP3] Re: Re: [PHP3] Problem with backslash in Windows paths From: Richard Lynch (lynch <email protected>)
Date: 03/17/99

At 10:10 AM 3/17/99, manuel.hossfeld <email protected> wrote:
>Rich,
>
>> I dunno what you did, but addslashes exists for this express purpose...
>
>That's what I also thought originally. But obviously addslashes() doesn't do
>what it's supposed to do - at least not in my case (and on PHP/Win32).
>
>I just tested it again... Try this code:
>
>---------
>// This is the string in question
>$str1 = "c:\somedir\test.txt";
>
>addslashes($str1);
>echo $str1; // gives: c:\\somedir est.txt
>
>// As opposed to...
>
>$str2 = 'c:\somedir\test.txt';// note the single quotes
> //- Thanks to Svein Parnas for this one; although
>I don't know why it works
>
>echo $str2; // gives: c:\somedir\test.txt
>---------
>
>So... Is this a bug or a feature? ;-)

A little of both, actually.

You see, as soon as you put quotes (") on it, PHP will look for variables
($foo) and backslashed characters \n \t \r ...

Try these (just for edification):

$str1 = "c:\\somedir\\test.txt";
echo $str1, "<BR>\n";
echo addslashes($str1), "<BR>\n";

$str2 = 'c:\somedir\test.txt';
echo $str2, "<BR>\n";
echo addslashes($str2), "<BR>\n";

-- "TANSTAAFL" Rich lynch <email protected> webmaster@ and www. all of:
R&B/jazz/blues/rock - jademaze.com music industry org - chatmusic.com
acoustic/funk/world-beat - astrakelly.com sculptures - olivierledoux.com
my own nascent company - l-i-e.com cool coffeehouse - uncommonground.com

--
PHP 3 Mailing List   http://www.php.net/
To unsubscribe send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest list:  php3-digest-subscribe <email protected>
For help: php3-help <email protected>  Archive:  http://www.php.net/mailsearch.php3
List administrator:  zeev-list-admin <email protected>