What is the significance of using $_SERVER['PHP_SELF'] instead of $PHP_SELF in PHP forms?

Using $_SERVER['PHP_SELF'] instead of $PHP_SELF in PHP forms is significant for security reasons. When using $PHP_SELF, there is a risk of cross-site scripting attacks as it can be manipulated by malicious users. $_SERVER['PHP_SELF'] provides a more secure way to access the current script name.

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