I'm trying to define a static variable for use in my custom module. I want it to let me pass a number from function to function. I'm using drupal_static()
but I can't get it to work. How do I do this?
This is the code I'm using to define my static variable.
$var = &drupal_static(__FUNCTION__);
if (!isset($var)) {
// generate contents of static variable
$var = '8';
}
return $var;
I've tried putting it in a custom module.
function viewusercontact_locateuser($value, $key, &$counter) {
global $user;
/**********In here***********/
if ($value['uid'] == $user->uid) {
........
}
}
I can't seem to get it to work. What am I doing wrong?
(I got my code from the following guides)
https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/drupal_static/7 http://www.lullabot.com/blog/article/beginners-guide-caching-data-drupal-7 http://erikwebb.net/blog/drupal-design-patterns/static