What are the potential pitfalls of using the "/e" modifier in preg_replace() for PHP?

Using the "/e" modifier in preg_replace() can be risky as it allows for the evaluation of PHP code within the replacement string, opening up the possibility of code injection attacks. To mitigate this risk, it is recommended to use the preg_replace_callback() function instead, which allows you to specify a callback function to handle the replacements safely.

// Using preg_replace_callback() to safely handle replacements
$string = "Hello, [name]!";
$replaced_string = preg_replace_callback('/\[name\]/', function($matches) {
    return "John";
}, $string);

echo $replaced_string;