Re: escaping characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



echo stripslashes("I\'m \"cool\"");

Works

I'm "cool"

On 13 June 2010 20:47, steve miller <steve@xxxxxxxxxx> wrote:
> Hi gentle,
>
> Guess I'm not explaining my problem well.
> I don't have problems removing slashes, I have problems placing the
> non-escaped text back into text that goes into an email I am sending.
>
> I think instead of trying to place the variable holding this text
> into an echo statement, I just store it all in a concatenated string
> and place that in the email.
>
> Thanks
>
>
> On Jun 13, 2010, at 2:40 PM, MLC wrote:
>
>> Try two preg_replace functions. Use the following patterns in the
>> first to
>> match:
>>
>> '/(\\\')/' replacing with a single quote.
>>
>> Use the following pattern for the second function:
>>
>> '/\\\"/' replacing with a double quote. If this one does not work,
>> leave
>> our the third backslash in the pattern.
>>
>> This should match only combinations of back slashes and single or
>> double
>> quote marks. You can run the function so that the result returns to
>> the
>> subject, as in:
>>
>> $subject = preg_replace('/\\\'/',"'",$subject);
>>
>> Let me know if this works.
>>
>> gentlemike2
>>
>> -----Original Message-----
>> From: php-objects@xxxxxxxxxxxxxxx [mailto:php-
>> objects@xxxxxxxxxxxxxxx] On
>> Behalf Of steve miller
>> Sent: Sunday, June 13, 2010 11:17 AM
>> To: php-objects@xxxxxxxxxxxxxxx
>> Subject: Re:  escaping characters
>>
>> But if I use stripslashes, won't I get something like
>>
>> echo "I'm "cool"";
>>
>> which would not work?
>>
>> On Jun 13, 2010, at 10:45 AM, Davide Baglieri wrote:
>>
>> > Just use stripslashes function.
>> >
>> > Il giorno 13/giu/2010, alle ore 16.09, steve miller
>> <steve@xxxxxxxxxx>
>> > ha scritto:
>> >
>> > > Oops; wasn't complete in my question!
>> > >
>> > > I don't have a problem in browsers because they ignore the
>> backslash
>> > > if I leave it in.
>> > > The problem is when I am creating an email because the email
>> > > applications don't ignore the backslash, but show it as \" or \'
>> > so I
>> > > have to remove them.
>> > >
>> > >
>> > > Steve
>> > >
>> > >
>> > >
>> > > On Jun 13, 2010, at 9:49 AM, steve miller wrote:
>> > >
>> > >> I have a simple but perplexing problem I could use some help
>> with.
>> > >>
>> > >> I am storing user text input strings in mysql, and am escaping '
>> > and
>> > >> " with addslashes.
>> > >> When I pull them out and use stripslashes, I sometimes get errors
>> > >> because I don't know if they have a ' or a " in the string.
>> > >>
>> > >> Example 1
>> > >> String is: I'm cool
>> > >> This works: echo "I'm cool";
>> > >> This does not: echo 'I'm cool';
>> > >>
>> > >> Example 2
>> > >> String is: You are "cool"
>> > >> This works: echo 'You are "cool"';
>> > >> This does not: echo "You are "cool"";
>> > >>
>> > >> Example 3
>> > >> String is: I'm "cool"
>> > >> This does not work: echo "I'm "cool"";
>> > >> This does not work: echo 'I'm "cool"';
>> > >>
>> > >> So, how do I output strings of unknown content?
>> > >>
>> > >> Thanks for any guidance.
>> > >>
>> > >> Steve
>> > >>
>> > >
>> > >
>> > >
>> > > [Non-text portions of this message have been removed]
>> > >
>> > >
>> > >
>> > > ------------------------------------
>> > >
>> > > Are you looking for a PHP job?
>> > > Join the PHP Professionals directory Now!
>> > > http://www.phpclasses.org/jobs/
>> > > Yahoo! Groups Links
>> > >
>> > >
>> > >
>> >
>>
>> [Non-text portions of this message have been removed]
>>
>> ------------------------------------
>>
>> Are you looking for a PHP job?
>> Join the PHP Professionals directory Now!
>> http://www.phpclasses.org/jobs/
>> Yahoo! Groups Links
>>
>>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> Are you looking for a PHP job?
> Join the PHP Professionals directory Now!
> http://www.phpclasses.org/jobs/
> Yahoo! Groups Links
>
>
>
>

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux