Home >Backend Development >PHP Tutorial >PHP imitates asp Application object online people statistics_PHP tutorial

PHP imitates asp Application object online people statistics_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:08:36895browse

php tutorial imitates asp tutorial application object online people statistics

Usage:
application('key','value'); //Set key=value
$value = application('key'); //Get the value of key
*/

function application()
{
$args = func_get_args(); //Get the 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(); //Prohibit 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 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 due to session_start
return $re;
}


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444858.htmlTechArticlephp tutorial imitates asp tutorial application object online people counting usage: application('key','value'); / /Set key=value $value = application('key'); //Get the value of key*/ function ap...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn