我需要明确PHP_SELF

I understand that it validate form data on the same page, but what if i want my form data to be handled by example.php can I use PHP_SELF and example.php together on some condition?

If you want to submit your form to the same page, i.e. PHP_SELF when a condition is met and submit it to example.php when a different condition is met, then try this:

<form method="POST" 
  action="<?php echo $some_condition == "some_value" ? $_SERVER['PHP_SELF'] : 'example.php'  ?>">
...
Your form content here
...
</form>

You will replace $some_condition == "some_value" with whatever condition you want to check.