Develop a module for drupal and I have to pass / modify the variable within the function. I had avoided using global variables because there is a function included in the Drupal which makes my local variable locally later
In this way, I have created the following script that stores a fixed variable But I can not have a new value. Any help would be appreciated
function _example_set_flashurl ($ value = '21224', $ clear = null) {static $ url; If ($ clear) {// Reset url variable back to default $ url = null; } // fixed url within this function a perminate value $ url = $ value; Return $ url; } Function _example_get_flashurl () {return _example_set_flashurl (); // retrieve the value within the set scope} _example_set_flashurl ('other', true); Print _example_get_flashurl (); // print 21224, I want to print it
try it
& lt;? Function _example_set_flashurl ($ value = '21224', $ clear = NULL) {static $ url; If ($ clear) {// Reset url variable back to default $ url = null; } If ($ value! = '21224') {// url = $ value within this function; } Return $ url; } Function _example_get_flashurl () {return _example_set_flashurl (); // retrieve the value within the set scope} _example_set_flashurl ('other', true); Print _example_get_flashurl (); // print 21224, I want to print it another
Comments
Post a Comment