-
- // Fix for removed Session functions
- function fix_session_register(){
- function session_register(){
- $args = func_get_args();
- foreach ($args as $key){
- $_SESSION[$key]=$GLOBALS[$key];
- }
- }
- function session_is_registered($key){
- return isset($_SESSION[$key]);
- }
- function session_unregister($key){
- unset($_SESSION[$key]);
- }
- }
- if (!function_exists('session_register')) fix_session_register();
- ?>
-
复制代码
找到了另外一个方法,直接把:
session_register( “abc” ) ;
改成
$_SESSION['abc'] = null;
即可
session在php5.3中的变化 (bbs.it-home.org 脚本学堂)
在php5.3中运行书中代码会有如下提示:
Function session_is_registered() is deprecated in
Function session_register() is deprecated in
即这两个函数是不赞成用了的,弃用的。
下面是php官方手册上的代码,注释部分已经说明了不赞成用session_register()
-
- // Use of session_register() is deprecated 不赞成用session_register()
- $barney = "A big purple dinosaur.";
- session_register("barney");
- // Use of $_SESSION is preferred, as of PHP 4.1.0 首选 $_SESSION
- $_SESSION["zim"] = "An invader from another planet.";
- // The old way was to use $HTTP_SESSION_VARS
- $HTTP_SESSION_VARS["spongebob"] = "He's got square pants.";
- ?>
-
复制代码
并且有如下警告及提示:
Warning
This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.
警告:这个函数在php5.3中已不推荐使用,在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.
提示:
如果 使用了$_SESSION,就用isset()函数来检查。
If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered() and session_unregister().
|