global-variables

phpDocumentor @global and @name question

First day I use phpDocumentor and so far so good, but I have a question that I didn't catch in the manual... The documentation of global variables. How would I document this code if: $someGlobalVar is not decalren in the PHP file of the class (it can even be undelared). $someGlobalVar is declared like this: $someGlobalVar = array(); (...

C++ Controlling destructor order for global objects

I've got a class (A) that accesses (indirectly via a static method) a static variable (an STL container) in another class (B) in its constructor and destructor. A objects may be global, global constants, static members of another class, stored in other classes (which may themselves have global or static instances) or basically anywhere ...

Accessing variable in kernel-space from user-level space

Hello, So let's I have a struct that I want to read from user-level space that is defined in the kernel-space, but the user-level space has multiple processes. Example: In a kernel module, I have a global struct. struct { int a; int b; } test; In a user-level module, I have "externed" that global struct extern struct { int a; ...

Does C++ call destructors for global and class static variables?

From my example program, it looks like it does call the destructors in both the cases. At what point does it call the destructors for global and class-static variables since they should be allocated in the data section of the program stack? ...

How can I define two global `const` variables to the same value in a C module?

I’m using a pair of global variables in one of my .c files, matched to a single extern declaration each in two different .h files (well, one .h file, preprocessed two ways). One is for public consumption, and one is for private use. Both are const variables. I only want to initialize one of the variables in my .c file, and then assign t...

Is it possible to simulate closures in PHP 5.2.x not using globals?

Is it possible to simulate closures in PHP 5.2.x not using globals? I could think of a way that would pass the desired variables as extra parameters to the closure but that just doesn't feel like best practice. Any ideas? ...

Storing a global struct variable inside another global struct in C

I’m trying to figure out a way to use nested global structs as a sort of API namespacing for my C library. Specifically, I want to expose a single Primary ‘namespacing struct,’ that contains other such structs (such as Primary.Secondary), that themselves contain function pointers (Primary.Secondary.a_function()). I’ve abstracted out th...

The advantage / disadvantage between global variables and function parameters in PHP?

sorry i'm a beginner and i can't determine how good a question this is, maybe it sounds utterly obvious to some of you. if our use of these two below is the same which is better? function doSomething ($var1,$var2,..){ ... } OR function doSomething (){ global $var1,$var2,..; ... } by our use I mean that I know that in t...

JavaScript: Is window.spam a good practice?

I've noticed all over the place people mention "Just define a variable in the top of your JS code and it becomes global" in response to questions like, "How do I create a global variable from inside a function?". Most of the answers start by saying it isn't possible to achieve that. Of course it is possible to do this: <script type="tex...

External SWF variable updates global variable in Main timeline

I have been searching all over and have yet to find an actual working solution for this I have 2 movie clips, one being loaded into a container MC via "loadMovie();" In the main movie there is a variable with no value, in the external movie there are 5 frames, each with a value to update the variable in the main movie. IE: if on fram...

Sharing variables between web workers? [global variables?]

Is there any way for me to share a variable between two web workers? (Web workers are basically threads in Javascript) In languages like c# you have: public static string message = ""; static void Main() { message = "asdf"; new Thread(mythread).Run(); } public static void mythread() { Console.WriteLine(message); //outputs "asdf" } ...

How do I declare an external char pointer?

File 1: static char* const path; //GLOBAL int main() { path = FunctionReturningPath(); UsePath() } File 2: extern char* const path; //GLOBAL from file 1 UsePath() //function using global { something = path; } (Pseudo) Would like to use path in file 2. I'm defining the global within main in file 1, is that bad practice u...

PHP: whats the total length of a post global variable?

Hi, I was wondering if anybody knows the total length that a post global could be. e.g: $_POST['formInput'] = "hello world, how long can i be?"; I am creating a site where someone will enter an unknown amount of chars into a textarea, so potentially it could be 2 pages on a word document. So if anybody knows of any other methods of h...

how to declare a global variable in Objective-C?

// MyClass.h @interface MyClass : NSObject { NSDictionary *dictobj; } @end //MyClass.m @implementation MyClass -(void)applicationDiDFinishlaunching:(UIApplication *)application { } -(void)methodA { // Here i need to add objects into the dictionary } -(void)methodB { //here i need to retrive the key and objects of Dictionary into a...

Accessing a Variable from Within a Doubly Nested Function in Python

The following code: x = 0 print "Initialization: ", x def f1(): x = 1 print "In f1 before f2:", x def f2(): global x x = 2 print "In f2: ", x f2() print "In f1 after f2: ", x f1() print "Final: ", x prints: Initialization: 0 In f1 before f2: 1 In f2: 2 In f1 aft...

Problem with accessing a global variable in PHP

Following is code snippet : function something() { $include_file = 'test.php'; if ( file_exists($include_file) ) { require_once ($include_file); // global $flag; // echo 'in main global scope flag='.$flag; test(); } } something(); exit; //in test.php $flag = 4; function test() { global $flag; echo '<br...

JavaScript: Global variables?

When I use code like this, it works fine: function removeWarning() { var systemStatus = document.getElementById("system-status"); systemStatus.innerHTML = ""; } function indicateInvalidUsername() { var systemStatus = document.getElementById("system-status"); systemStatus.innerHTML = "Invalid username"; } However, when...

how to have global variables among different modules in Python

hello, I investigated that scope of global variables in python is limited to the module. But I need the scope to be global among different modules. Is there such a thing? I played around __builtin__ but no luck. thanks in advance! ...

Two different instances of the same class are confusing variables

Hi, Why do two different instances of the same class are using their variables as if they where static variables? I do not want to synthesize those variables. But without synthesizing- both instances refer to their variables as if they where the same one. Any way to go around it? Why is that so? Thanks- Nir. ...

php classes dont work inside another class, but works outside global

i have this http://pastie.org/836744 script, which works outside the class completely fine, but it does not work inside another class, i have added the global vars in method too, which are being used inside other functions, but that didnt work. following is demo code include_once("prayer_calculation.inc.php"); $prayers = get_prayer_ti...