What are the potential security risks of embedding PHP scripts within XML nodes?

Embedding PHP scripts within XML nodes can lead to security risks such as code injection and execution of malicious scripts. To mitigate this risk, it is recommended to avoid embedding PHP scripts directly within XML nodes. Instead, consider using a templating engine or separating the PHP logic from the XML content.

// Example of separating PHP logic from XML content
<?php
// PHP logic
$data = [
    'name' => 'John Doe',
    'age' => 30
];

// XML content
$xml = '<?xml version="1.0" encoding="UTF-8"?>
<user>
    <name>' . $data['name'] . '</name>
    <age>' . $data['age'] . '</age>
</user>';

echo $xml;
?>