This function is used to defined global variable based on file system
and can be accessed anywhere in the file. It is similar to Application
variable of ASP or ASP.NET Technology.
The directory temp dir should have 777 permission.
*/
function appVar($action,$temp_path,$varname,$value=""){
if($action == "set"){
if(!(fwrite(fopen($temp_path . $varname, 'w'),serialize($value))))
echo "[Error: file system/permission problem : $temp_path.$varname]";
$state = "";
}
if($action == "get"){
if(!($strvalue = implode("",file($temp_path . $varname)))) echo
"[Error: retrieving problem, file : $temp_path.$varname]";;
$value = unserialize($strvalue);
$state = $value;
}
return $state;
}
// Example
appVar("set","/temp","username","Zeeshan");
echo appVar("get","/temp","username","");
?>