Php imitating the aspApplication object online count statistics implementation method _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Php imitates the implementation method of online number statistics of aspApplication objects. Php imitating aspApplication object online number statistics implementation method this article mainly introduces php imitating asp Application object online number statistics implementation method, through a simple custom php imitating asp Application object online number statistics implementation method

This article mainly introduces php's implementation method of imitating asp Application object's online number of people Statistics. Using a simple user-defined function, this function has some reference value, for more information, see

This example describes how php simulates asp Application object online count statistics. Share it with you for your reference. The specific implementation method is as follows:

The code is as follows:

/*
Usage:
Application ('key', 'value'); // set key = value
$ Value = application ('key'); // Obtain the key value
*/

Function application ()
{
$ Args = func_get_args (); // Obtain the input parameter
If (count ($ args)> 2 | count ($ args) <1) return;
$ Ssid = session_id (); // save the current session_id
Session_write_close (); // ends the current session
Ob_start (); // disable the global session from sending the header.
Session_id ("xxx"); // register global session_id
Session_start (); // enable global session
$ Key = $ args [0];
If (count ($ args) = 2) // if the second parameter exists, it indicates that the global session is written.
{
$ Re = ($ _ session [$ key] = $ args [1]);
}
Else // if there is only one parameter, the value corresponding to this parameter is returned
{
$ Re = $ _ session [$ key];
}
Session_write_close (); // end the global session
Session_id ($ ssid); // re-register the non-global session interrupted above
Session_start (); // restart
Ob_end_clean (); // discard some header output due to session_start.
Return $ re;
}

I hope this article will help you with php programming.

Application object online number of people Statistics implementation method this article mainly introduces php imitation asp Application object online number statistics implementation method, through a relatively simple custom...

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.