php 未定义变量 PHP_SELF

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12710803/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 04:05:51  来源:igfitidea点击:

Undefined Variable PHP_SELF

phpcontent-management-system

提问by adadeh

I am developing a backend with php here.

我在这里用 php 开发后端。

I am having problem with such error like this:

我遇到了这样的错误问题:

Undefined variable : PHP_SELF

未定义变量:PHP_SELF

on my htdocs directory.

在我的 htdocs 目录中。

I'm developing with php 5.4.4 , and if you want to look at the source code here it is:

我正在使用 php 5.4.4 进行开发,如果您想查看这里的源代码,它是:

http://pastebin.com/xr2PxbNG

http://pastebin.com/xr2PxbNG

回答by Sven

Do not use any of the suggested versions of PHP_SELF. It is a security nightmare, opening up your PHP to a multitude of possible injection attacks.

不要使用任何建议的 PHP_SELF 版本。这是一个安全噩梦,让您的 PHP 面临多种可能的注入攻击。

What are you trying to achieve? Generate the URL for a form sending to itself? Use action=""for that - it is a valid approach and will always use the URL for sending the form as for loading.

你想达到什么目的?为发送给自身的表单生成 URL?action=""为此使用- 这是一种有效的方法,并且将始终使用 URL 来发送表单作为加载。

If you must know the requested script, use $_SERVER['SCRIPT_NAME']instead.

如果您必须知道请求的脚本,请$_SERVER['SCRIPT_NAME']改用。

回答by Baba

You are using $PHP_SELFit should be

你正在使用$PHP_SELF它应该是

echo $_SERVER['PHP_SELF'] ;

Or

或者

$PHP_SELF = &$_SERVER['PHP_SELF'];
echo $PHP_SELF ;

You can also have

你也可以拥有

define("PHP_SELF",$_SERVER['PHP_SELF']); 
echo PHP_SELF ;

回答by Lkrups

Are you trying to access $_SERVER['PHP_SELF'] ?

您是否正在尝试访问 $_SERVER['PHP_SELF'] ?

回答by Anson Kao

Looks like certain WordPress distributions declare $PHP_SELF = $_SERVER['PHP_SELF']for reasons I can't say, must be some sorta legacy thing.

看起来某些 WordPress 发行版声明$PHP_SELF = $_SERVER['PHP_SELF']的原因我不能说,一定是某种遗留的东西。

回答by Harshal Solanki

I have to Solve This Error Using Page Url... Ex. Like

我必须使用页面 URL 解决此错误...例如。喜欢

echo "<a href=\"$_PHP_SELF?page=$last\">Last 3 Records</a>";

You Have to remove $_PHP_SELF and use page URL insert.php .......

您必须删除 $_PHP_SELF 并使用页面 URL insert.php .......

回答by bhanu

I was getting the same, Notice: Undefined variable _PHP_SELF So I just replaced $_PHP_SELF to $_SERVER[PHP_SELF] Now I don't get any extra no

我得到了同样的,注意:未定义的变量 _PHP_SELF 所以我只是将 $_PHP_SELF 替换为 $_SERVER[PHP_SELF] 现在我没有得到任何额外的没有

回答by Scott C Wilson

Some shells will erase the value of $_SERVER['PHP_SELF']as a security measure. You may need to look at $_SERVER['argv'][0]if this is what is happening to you.

$_SERVER['PHP_SELF']作为一种安全措施,一些 shell 会擦除 的值。您可能需要看看$_SERVER['argv'][0]这是否是发生在您身上的事情。

回答by Zorro Sistemas

I solved starting the variable:

我解决了启动变量:

$PHP_SELF = NULL;
$Path1 = realpath(substr($PHP_SELF, 1));
$dbName = "$Path1\BD.accdb";