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

Common pitfalls when using the eval() function in PHP include security vulnerabilities due to executing arbitrary code, potential performance issues, and difficulty in debugging and maintaining code. To avoid these pitfalls, it is recommended to avoid using eval() whenever possible and find alternative solutions such as using built-in PHP functions or implementing dynamic code execution in a safer way.

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