Home >Backend Development >PHP Tutorial >PHP session_register function (with detailed explanation)
Usage of PHP session_register function
Syntax:
boolean session_register(string name);
Register new variables.
Return value: Boolean value
Function type: Data processing
Content description:
This function adds a variable to the current Session in the global variable. The parameter name is the name of the variable to be added. Returns true value on success.
If you open the session in the header file, that is, use the session_start() function followed by session_register(string name) (such as session_register('username')), then this variable will become a global variable and will affect all Use the file that calls session_start().
Example:
<?PHP session_start(); $username = ‘test’; session_register(‘username’); echo $_session['username']; //输出test ?>
Thank you everyone for reading, I hope you will benefit a lot.
Recommended tutorial: "PHP Tutorial"
The above is the detailed content of PHP session_register function (with detailed explanation). For more information, please follow other related articles on the PHP Chinese website!