NYCPHP Meetup

NYPHP.org

[nycphp-talk] Bug in PHundamentals function?

Aaron Fischer agfische at email.smith.edu
Mon Oct 3 20:15:45 EDT 2005


Chris Shiflett wrote:

>Aaron Fischer wrote:
> > $sb_string = "I\'\'m heading out on the road";
>
>You don't have to escape single quotes when you enclose the string with 
>double quotes. I wrote a bit more on quoting strings here:
>
>  
>
Right, I know that.  In this case I was attempting to recreate a string 
that would represent, say, a POST['var'] on a server that had 
magic_quotes_gpc turned on.   So I wanted the escape slash to be a part 
of the string so I could then test stripslashes on it.

It string var was actually supposed to be:
$sb_string = "I\'m heading out on the road";

Then:
$sb_string_new = stripslashes($sb_string);
// escape slash should be removed

>http://shiflett.org/archive/140
>
>  
>
Cool link.

>Dan Cech wrote:
> > return $sybase ? str_replace ("''", "'", $var) : stripslashes ($var);
>
>I prefer this approach when it helps me avoid escaping. In this case, I 
>think both look confusing, but the escaping makes it worse.
>
>  
>
This looks better to me too (but what do I know?).

-Aaron



More information about the talk mailing list