正确答案 To store a global variable, store it in
$GLOBALS
superglobal.
Or, perhaps, you can use a static value.
$GLOBALS
: http://php.net/manual/en/reserved.variables.globals.php
static
variables: http://php.net/manual/en/language.oop5.static.php
欢迎各位兄弟 发布技术文章
这里的技术是共享的
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");}
4 |
| ||
2 |
| ||||
|
0 |
|
Actually,
popmeup_page()
, andpopmeup_comment_instert()
are called in two different page requests. This means that any global, or static variable is reset, and the value passed to those variables is not kept. – kiamlaluno Jan 2 '13 at 15:53