php imitates asp Application object online people counting implementation method, application object
The example in this article describes the implementation method of online people counting by php imitating the asp Application object. Share it with everyone for your reference. The specific implementation method is as follows:
Copy code 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 the current session_id
session_write_close(); //End the current session
ob_start(); //Disable global session from sending header
session_id("xxx"); //Register global session_id
session_start(); //Open global session
$key = $args[0];
if (count($args) == 2) //If there is a second parameter, it means writing to the global session
{
$re = ($_session[$key] = $args[1]);
}
else // If there is only one parameter, then return the value corresponding to the parameter
{
$re = $_session[$key];
}
session_write_close(); //End global session
session_id($ssid); //Re-register the interrupted non-global session
session_start(); //Restart
ob_end_clean(); //Discard some header output just generated by session_start
return $re;
}
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/937086.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/937086.htmlTechArticlephp imitates asp Application object online people counting implementation method, application object This article tells the example of php imitating asp Application object online people Statistical implementation methods. Share it with everyone...