[nycphp-talk] Bug in PHundamentals function?
Aaron Fischer
agfische at email.smith.edu
Mon Oct 3 19:24:56 EDT 2005
Dan Cech wrote:
>Aaron,
>
>As it happens I wrote the line in question, so I'll try and explain
>what's going on ;)
>
>
>
Most appreciated Dan!
>I think that you're confused about the effect of the magic_quotes_sybase
>php.ini directive.
>
>
>
Hmmm, that doesn't surprise me.
>Say you had the string:
>
>I'm heading out on the road
>
>With magic_quotes_gpc=On and magic_quotes_sybase=Off, the string coming
>in would look like:
>
>I\'m heading out on the road
>
>With magic_quotes_gpc and magic_quotes_sybase both On, the string coming
>in would look like:
>
>I''m heading out on the road
>
>So, in php/english the idea of that line is:
>
>if (magic_quotes_sybase = On) {
> // replace '' with '
> return str_replace ('\'\'', '\'', $var)
>} else {
> // use regular stripslashes
> return stripslashes ($var)
>}
>
>You could also write the line as:
>
>return $sybase ? str_replace ("''", "'", $var) : stripslashes ($var);
>
>to have the same effect, but I tend to prefer using single-quoted
>strings unless I'm actually embedding \n line breaks or variables, so I
>went with the single-quotes-and-slashes encoding.
>
>Dan
>
>
Gotcha. I was thrown off by misinterpreting the search and replace strings.
Thanks, that's very helpful!
Cheers,
-Aaron
More information about the talk
mailing list