4 ms·
"preg_replace with the /e (eval) flag will do a string replace of the matches into the replacement string, then eval it." The mind reels.
by sneak 15y ago
"preg_replace with the /e (eval) flag will do a string replace of the matches into the replacement string, then eval it."
The mind reels.
- astrodust 15y agoYou can blame Larry Wall (Perl) for that one. It's amazingly powerful but also the stuff of nightmares in the wrong hands.
- eevee 15y agoNope. This works as you'd expect in Perl: the replacement is treated as code and executed like an inline function, never eval'd.
- astrodust 15y agoIf you're implying that `/e` is more dangerous in PHP than in Perl, then that is truly terrifying.
- shabble 15y agoYep, that's why s///ee exists :) http://perldoc.perl.org/perlop.html#s/PATTERN/REPLACEMENT/msixpodualgcer http://perldoc.perl.org/perlop.html#s/PATTERN/REPLACEMENT/ms... "e Evaluate the right side as an expression. ee Evaluate the right side as a string then eval the result."