I know it’s stupid question, but I cannot to google anything for my problem.
I have $q = "This is\\same text"; and do
$q = stripslashes($q);
So, $q is now equal to "This issame text"! How I can to save one backslash?
Thank you.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The script does, what it’s told, actually.
In
$q, the double backslash evaluates to a single backslash (the first escapes the second backslash), which is then stripped away.If meta-characters are not to be evaluated, you’ll need to use single quotes:
EDIT
According to your comment in Michaels answerthere may be some confusion as to how many valid backslashes there are in your input. Consider the following input:The first would actually contain
This is \\some <TAB>ext. This is due to PHP leaving invalid control characters as-is.\s, as opposed to\tis an invalid control character and is thus left in place.The second string, however, would literally contain what’s in the single quotes, since no evaluation is applied.