What are the potential security risks of passing variables through iframes in PHP?

Passing variables through iframes in PHP can pose security risks such as cross-site scripting (XSS) attacks or data manipulation. To mitigate these risks, it is important to properly sanitize and validate any user input before passing it through iframes. This can be done by using functions like htmlentities() to encode any special characters and prevent XSS attacks.

// Sanitize and validate user input before passing it through iframes
$variable = htmlentities($_POST['variable']);
echo "<iframe src='example.php?variable=$variable'></iframe>";