Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4093320
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:36:12+00:00 2026-05-20T19:36:12+00:00

Developing a module for drupal and I need to pass/modify variables within functions. I

  • 0

Developing a module for drupal and I need to pass/modify variables within functions. I avoided using global variables because drupal uses the include function which subsequently makes my global variable into local.

As such, i created the following script which stores a static variable but I cannot retain the new value. Any help will be appreciated

function _example_set_flashurl($value = '21224', $clear = NULL) {
  static $url;

  if ($clear) {
    // reset url variable back to default
    $url = null;
  }
  // assigned url a perminate value within this function
  $url = $value;
  return $url;


}

function _example_get_flashurl() {
  return _example_set_flashurl();
  // retrieve the value inside set scope
}
_example_set_flashurl('another', TRUE);
print _example_get_flashurl();  // prints 21224,  I want it to print another 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T19:36:13+00:00Added an answer on May 20, 2026 at 7:36 pm

    Try this

    <?
    function _example_set_flashurl($value = '21224', $clear = NULL) {
      static $url;
    
      if ($clear) {
        // reset url variable back to default
        $url = null;
      }
      if($value!='21224') {
      // assigned url a perminate value within this function
      $url = $value;
      }
      return $url;
    
    
    }
    
    function _example_get_flashurl() {
      return _example_set_flashurl();
      // retrieve the value inside set scope
    }
    _example_set_flashurl('another', TRUE);
    print _example_get_flashurl();  // prints 21224,  I want it to print another
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a drupal module. I'm using only 2 hooks (hook_menu, hook_cron) In hook_menu,
I'm developing a simple custom Drupal Module for creating Quizz, and I need some
iam developing a module in Drupal, which needs to have a locking machanism, When
I'm currently developing a module for Drupal 6, in which I have created a
I am developing a module in DNN 4.9 to import users. I need transaction
I am developing a kernel module that uses unlocked_ioctl. I tested it with kernel
In a module I am developing, I am using the following code. function mymodule_page_alter(&$page)
In the Dot Net Nuke module that I'm developing I need to separate the
I'm using Development Seed's fantastic Context module (version 6.x-2.0) for Drupal 6 on a
I am developing a chat module for drupal. I plan to provide multiple backends

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.