Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

html - Is './' a valid path to submit a form to the same page for processing with PHP?

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...