What are common pitfalls when using the eval() function in PHP scripts?

Common pitfalls when using the eval() function in PHP scripts include security vulnerabilities, potential for code injection attacks, and decreased performance due to the dynamic nature of the function. To avoid these pitfalls, it is recommended to avoid using eval() whenever possible and instead find alternative methods to achieve the desired functionality.

// Avoid using eval() function
$code = "echo 'Hello, World!';";
eval($code); // Avoid using eval() function