I am trying to save a global variable in my module and access it from another function. I don’t want to store it in $_SESSION because I need this variable application wide. Following is the code what I am trying but it simply doesn’t work.
function popmeup_menu() {
$items['example/feed'] = array(
'title' => 'Example RSS feed',
'page callback' => 'popmeup_page',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK
);
return $items;
}
function popmeup_page() {
print variable_get($xmlt, "");
}
function popmeup_comment_insert($comment) {
variable_set($xmlt,"xmltoreturn");
}
To store a global variable, store it in
$GLOBALSsuperglobal.Or, perhaps, you can use a static value.
$GLOBALS: http://php.net/manual/en/reserved.variables.globals.phpstaticvariables: http://php.net/manual/en/language.oop5.static.php