Session changes in php5.3 session_is_registered () is deprecated in_php tutorial

Source: Internet
Author: User
Tags deprecated
Running the code in php5.3 will prompt you with the following:
Function session_is_registered () is deprecated in
Function session_register () is deprecated in

This means that these two functions are deprecated.

The following is the code in the official PHP manual, which has been explained in the comments section that does not agree with Session_register ()

Copy the Code code as follows:
Use of Session_register () is deprecated disapproval with session_register ()
$barney = "A big purple Dinosaur.";
Session_register ("Barney");

Use of $_session is preferred, as of PHP 4.1.0 First Choice $_session
$_session["Zim"] = "an invader from another planet.";

The old $HTTP _session_vars
$HTTP _session_vars["SpongeBob"] = "He s got square pants.";
?>

The following warnings and hints are available:
Warning
This function has been DEPRECATED as of PHP 5.3.0 and removed as of PHP 5.4.0.
Warning: This function has been deprecated in php5.3 and has been removed in php5.4.

Note:
If $_session (or $HTTP _session_vars for PHP 4.0.6 or less) are used, use Isset () to check a variable is registe Red in $_session.
Tip: Use the isset () function to check if $_session is used.

Caution
If you is using $_session (or $HTTP _session_vars), do not use Session_register (), session_is_registered () and SESSION_UNR Egister ().

php5.3 not supported Session_register () This function has been removed (workaround)

PHP upgrade from 5.2.x to 5.3.2. It's out of the question. Some of the original procedures can be used to error.
Error content is
Deprecated:function Session_register () is Deprecated
Check it is 5.3 This session_register will not let use, down back? Upset.
A search, one solution is to write a function
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 ();
?>

Look at the problem there is not many places, found another way, directly
Put
Session_register ("abc");
Change into
$_session[' abc '] = null;
Can

http://www.bkjia.com/PHPjc/825201.html www.bkjia.com true http://www.bkjia.com/PHPjc/825201.html techarticle the code in the php5.3 runs in the book with the following hint: function session_is_registered () is deprecated in Function session_register () are deprecated in It means that these two functions are not good ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.