PHP imitate ASP Application object online population statistic realization method, Application Object
In this paper, we describe the method of PHP imitating ASP Application object online population statistic. Share to everyone for your reference. The implementation method is as follows:
Copy the Code Code as follows:/*
Usage:
Application (' key ', ' value '); Set Key=value
$value = Application (' key '); Get the value of key
*/
function Application ()
{
$args = Func_get_args (); Get input parameters
if (count ($args) >2 | | count ($ARGS) < 1) return;
$ssid = session_id (); Save current session_id
Session_write_close (); End Current session
Ob_start (); Disable Global Session Send header
session_id ("xxx"); Registering a global session_id
Session_Start (); Turn on global session
$key = $args [0];
if (count ($args) = = 2)//If there is a second argument, then the global session is written
{
$re = ($_session[$key] = $args [1]);
}
else//If there is only one argument, return the value corresponding to the parameter
{
$re = $_session[$key];
}
Session_write_close (); End Global Session
session_id ($SSID); Re-registering a non-global session that was interrupted above
Session_Start (); Re-open
Ob_end_clean (); Discard some header output just because of session_start
return $re;
}
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/937086.html www.bkjia.com true http://www.bkjia.com/PHPjc/937086.html techarticle PHP imitate ASP Application object online population statistic realization method, Application object This article narrates PHP to imitate ASP Application object online population statistic realization method. To share with you ...