Re: How do I create my own addslashes() style routine for NT directories?
| From: | Robin Vickery | Date: | Fri, 11 Aug 2000 08:25:25 +0000 |
| Subject: | Re: How do I create my own addslashes() style routine for NT directories? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11282@lists.php.net to get a copy of this message | ||
DayWalker@TheMatrix.com ("Daevid Vincent") writes:
> We have a database that is supposed to store typical NT fashion paths:
> \\NTSERVER\some\directory\here\
> But I can't figure out how in the heck to get it to save and retrieve in
> tact.
>
> If you exectute the code below, you will see the results at the bottom of
> the page.
> (I can't get the ereg_replace() function to work).
>
> So, it seems that addslashes() is a bit 'too smart' for it's own good.
> instead of blindly just converting my $script to
> "set basedir=\\\\NTSERVER\\some\\directory\\here\\ \n"
> it assumes that I meant to escape the \\ as is written and skips it! grrrr.
> thereby creating
> "set basedir=\\NTSERVER\\some\\directory\\here\\ \n"
> which is close but no cigar.
>
> Anyone have a solution around this annoyance? The situation is compounded by
> the fact that there are in deed characters that I want to be just what they
> are, such as the \n character. In this case, the add/stripslashes() routines
> work perfectly. It's only the case of when it sees \\ that it becomes a
> problem.
If you're using PHP4 and you want more control over what's escaped and
what isn't, you can use AddCSlashes(string str, string charlist).
http://www.php.net/manual/function.addcslashes.php
-robin
--
Robin Vickery...............................................
Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UK
Email: robin@planet-three.net Phone: +44 (0)794 670 6395