session在php5.3中的变化


在php5.3中运行书中代码会有如下提示:
Function session_is_registered() is deprecated in
Function session_register() is deprecated in

意思是说这两个函数是不赞成的,弃用的。
下面是php官方手册上的代码,注释部分已经说明了不赞成用session_register()

1

2

3

4

5

6

7

8

9

10

11

<?php

// 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中已被移除。

Note:
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()函数来检查。

Caution
If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered() and session_unregister().


你可能感兴趣的:(session在php5.3中的变化)