php 中的 register_globals 错误

use*_*862 2 php php.ini

我被错误所困扰

directive 'register_globals' is no longer available in PHP in unknown on line 0
Run Code Online (Sandbox Code Playgroud)

register_globals在 php.ini 文件中启用后尝试使用“php -v”检查 php 版本时。这样做我没有得到任何 php 版本信息。相反,它会抛出上述错误。关闭此选项后,php info 运行良好。打开 register_globals 对我来说非常重要。我该如何纠正这个问题。

php.ini的如下:

; Default Value: None
; Development Value: "GP"
; Production Value: "GP"
; http://php.net/request-order
request_order = "GP"

; Whether or not to register the EGPCS variables as global variables.  You may
; want to turn this off if you don't want to clutter your scripts' global scope
; with user data.
; You should do your best to write your scripts so that they do not require
; register_globals to be on;  Using form variables as globals can easily lead
; to possible security problems, if the code is not very well thought of.
; 
register_globals = On

; Determines whether the deprecated long $HTTP_*_VARS type predefined variables
; are registered by PHP or not. As they are deprecated, we obviously don't
; recommend you use them. They are on by default for compatibility reasons but
; they are not recommended on production servers.
; Default Value: On
; Development Value: Off
; Production Value: Off
; 
register_long_arrays = Off

; This directive determines whether PHP registers $argv & $argc each time it
; runs. $argv contains an array of all the arguments passed to PHP when a script
; is invoked. $argc contains an integer representing the number of arguments
; that were passed when the script was invoked. These arrays are extremely
; useful when running scripts from the command line. When this directive is
; enabled, registering these variables consumes CPU cycles and memory each time
; a script is executed. For performance reasons, this feature should be disabled
; on production servers.
; Note: This directive is hardcoded to On for the CLI SAPI
; Default Value: On
; Development Value: Off
; Production Value: Off
;
register_argc_argv = Off

; When enabled, the SERVER and ENV variables are created when they're first
; used (Just In Time) instead of when the script starts. If these variables
; are not used within a script, having this directive on will result in a
; performance gain. The PHP directives register_globals, register_long_arrays,
; and register_argc_argv must be disabled for this directive to have any affect.
;
auto_globals_jit = On
Run Code Online (Sandbox Code Playgroud)

Mic*_*ton 9

文档

此功能自 PHP 5.3.0 起已弃用,自 PHP 5.4.0 起已移除。

您可以降级 PHP,或者register_globals从 php.ini 文件中删除并修复引用它的任何代码。后者是优选的。

  • 或者说具体一点。他需要从他的 ini 文件中注释掉/删除对 `register_globals` 的任何引用。 (4认同)