What potential issues can arise from using $_SERVER['PHP_SELF'] in PHP code?

Using $_SERVER['PHP_SELF'] in PHP code can potentially lead to security vulnerabilities such as cross-site scripting (XSS) attacks. To mitigate this risk, it is recommended to use htmlspecialchars() function to escape any HTML entities before outputting the variable.

<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
    <!-- form elements go here -->
</form>