I am submitting an HTML form to the same page to handle with PHP and figured out that I can use action="./"
, which works fine for me so far (in a test environment).
I am a little unsure though because all the examples I find recommend using either
action=""
or
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>"
I don't want to use action=""
because the HTML Standard specifically states
The action and formaction content attributes, if specified, must have a value that is a valid non-empty URL potentially surrounded by spaces.
Is there any reason not to use action="./"
? It seems better (more readable, less PHP) to me but it's confusing me that all the examples I find recommend the PHP approach.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…