Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand that PHP register_ globals are on and off

Shulou Source: shulou.com Published: 2022-06-03 07:37:46 11月15日 Update

This article mainly introduces "how to understand PHP register_globals value is on and off", in daily operation, I believe many people have doubts on how to understand PHP register_globals value is on and off, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation method, hope to answer "how to understand PHP register_globals value is on and off" doubts helpful! Next, please follow the small series to learn together!

The value of register_globals can be set to either On or Off. Let's take a code to describe the difference between them.

Code:

The copy code is as follows:

When register_globals=Off, the next program to receive should receive the value with $_GET <$'user_name'] and $_GET <$'user_pass']. (Note: $_POST <$'user_name') and $_POST <$'user_pass') should be used when the method attribute is post.

When register_globals=On, the next program can accept values directly using $user_name and $user_pass.

Register_globals, as the name suggests, means to register as a global variable, so when On, the value passed in will be registered directly as a global variable, and when Off, we need to go to a specific array to get it. So, those of you who have problems with getting values above should first check that your register_globals setting matches the way you get values. (This can be done with phpinfo() or by looking directly at php.ini)

Let's see what's wrong here.

Take a look at this PHP script that grants access to a Web page when the username and password are entered correctly:

The copy code is as follows:

Please enter your username and password:

Tags: Code time user learning variable password user name problem global method more program face-to-face help check different practical security as the name implies next Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Xiaomi Linux MySQL Docker