Date: 05/05/00
- Next message: Andrei Zmievski: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Previous message: Andrei Zmievski: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- In reply to: Andrei Zmievski: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Next in thread: Andrei Zmievski: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Reply: Andrei Zmievski: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 08:57 5-5-2000 -0500, Andrei Zmievski wrote:
>On Fri, 05 May 2000, Wico de Leeuw wrote:
> > Wouldn't it be easyer if php would just putt it also in the var $1 wich
> you
> > can pass to the function?
>
>No, it wouldn't really solve your problem. Internally, when you call
>preg_replace() with /e PHP constructs a string to be evaluated by
>substituting the captured subpatterns in place of \\n. So, even if you
>used $1 and AddSlashes($1), internally, it would end up being:
>
>AddSlashes('foo' and "not" 'foo') (or something like that)
>
>This string is passed off to Zend for evaluation and Zend, of course,
>fails because of the parser error. Even if you do AddSlashes("$1"), you
>are not safe because then you have a different parse error due to
>quotes (and "$1" is the same as "\\1", for all it matters).
>
> > btw if i would fist escape the ' an " in a preg_replace i wouldn't need
> the
> > second to do an addslashes on it :)
>
>So, just use preg_replace() to do what addslashes() does.
>
>$text = preg_replace("/['"]/", "\\\\0", $text);
Ok tnx,
but what about the 0 code in php?
>-Andrei
>
>'Any given program, when running correctly, is obsolete.'
> - First Law of Computer Programming
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Andrei Zmievski: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Previous message: Andrei Zmievski: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- In reply to: Andrei Zmievski: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Next in thread: Andrei Zmievski: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Reply: Andrei Zmievski: "Re: [PHP-DEV] preg_replace and e option (bug or feature?)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

