how does this php form work without defining variable?
how does this php form work without defining $SCRIPT_NAME variable ?
<form action="<?php echo $S开发者_StackOverflowCRIPT_NAME ?>" method="post">
This code relies on the ancient, deprecated and horrible register_globals
feature which creates global variables from all the $_REQUEST
, $_COOKIE
and $_SERVER
fields.
I'd highly suggest you to get rid of this code and disable the register_globals
setting.
There is a variable, $_SERVER['SCRIPT_NAME'] that prints out the name of the current script. You can find some information on it here: http://php.net/manual/en/reserved.variables.server.php
I would suspect that is what is being used.
The variable $_SERVER['PHP_SELF']
will give you the relative path of the executing script, as well as the variable $_SERVER['SCRIPT_NAME']
gives the current script name.
An alternative would be to use $_SERVER['SCRIPT_FILENAME']
or the constant FILE, which each give the absolute path.
Those should be preferred and used instead of using the register-globals
feature which should be disabled as @ThiefMaster said.
精彩评论