What is the best practice for specifying the action attribute in a form tag in PHP?

When specifying the action attribute in a form tag in PHP, it is best practice to use the $_SERVER['PHP_SELF'] variable to ensure that the form data is submitted to the same PHP script that is processing the form. This helps prevent security vulnerabilities such as cross-site scripting attacks and ensures that the form data is handled securely.

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