开发者

how does this php form work without defining variable?

开发者 https://www.devze.com 2023-03-03 04:40 出处:网络
how does this php form work without defining $SCRIPT_NAME variable ? <form action=\"<?php echo $S开发者_StackOverflowCRIPT_NAME ?>\" method=\"post\">

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消