What are potential security risks associated with using the eval function in PHP?

Using the eval function in PHP can introduce security risks such as code injection and execution of malicious code. It is recommended to avoid using eval whenever possible to prevent these vulnerabilities.

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