Home  >  Article  >  Backend Development  >  php5.3 does not support session_register(). What should I do if this function is enabled?

php5.3 does not support session_register(). What should I do if this function is enabled?

WBOY
WBOYOriginal
2016-07-25 08:52:54763browse
  1. // Fix for removed Session functions
  2. function fix_session_register(){
  3. function session_register(){
  4. $args = func_get_args();
  5. foreach ($args as $key){
  6. $_SESSION [$key]=$GLOBALS[$key];
  7. }
  8. }
  9. function session_is_registered($key){
  10. return isset($_SESSION[$key]);
  11. }
  12. function session_unregister($key){
  13. unset($ _SESSION[$key]);
  14. }
  15. }
  16. if (!function_exists('session_register')) fix_session_register();
  17. ?>
Copy code

I found another method, just put: session_register( “abc” ); Change to $_SESSION['abc'] = null; That’s it

Changes in session in php5.3 (bbs.it-home.org Script School) When running the code in the book in php5.3, you will get the following prompt: Function session_is_registered() is deprecated in Function session_register() is deprecated in That is to say, these two functions are deprecated and deprecated.

The following is the code from the official PHP manual. The comments section has stated that session_register() is deprecated.

  1. // Use of session_register() is deprecated
  2. $barney = "A big purple dinosaur.";
  3. session_register("barney");
  4. // Use of $_SESSION is preferred, as of PHP 4.1.0 "] = "He's got square pants.";
  5. ?>
  6. Copy the code
and there are the following warnings and tips: Warning This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.
Warning: This function is deprecated in php5.3 and has been removed in php5.4. If $_SESSION (or $HTTP_SESSION_VARS for PHP 4.0.6 or less) is used, use isset() to check a variable is registered in $_SESSION.

Tips: If $_SESSION is used, use the isset() function to check. If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered() and session_unregister().

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn