PHP Simulation of ASP Application object online population Statistics implementation method
This article mainly introduces PHP imitate ASP Application object online population statistic realization method, realizes this function through a relatively simple custom function, has the certain reference value, the need friend can refer to the next
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:
The code is 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/975902.html www.bkjia.com true http://www.bkjia.com/PHPjc/975902.html techarticle PHP imitate ASP Application object online Population Statistic Realization method This article mainly introduces PHP imitate ASP Application object online population statistic realization method, through a relatively simple custom ...