A variable is a named data storage location in memory. Using variables, a computer program can store numbers, text, binary data, or a combination of any of these data types. They can be passed around in code, to other functions and even other applications.

learn more… | top users | synonyms (1)

389
votes
9answers
109k views

JavaScript Variable Scope

What is the scope of variables in javascript? Do they have the same scope inside as opposed to outside a function? Or does it even matter? Also, where are the variables stored if they are defined ...
87
votes
7answers
21k views

How does an underscore in front of a variable in a cocoa objective-c class work?

I've seen in a few iPhone examples that attributes have used an underscore _ in front of the variable. Does anyone know what this means? or how it works? an interface file I'm using looks like: ...
11
votes
5answers
46k views

How to pass JavaScript variables to PHP?

I want to pass JavaScript variables to PHP using a hidden input in a form. But I can't get the value of $_POST['hidden1'] into $salarieid. Is there something wrong? Here is the code: <script ...
15
votes
5answers
720 views

Using i and j as variables in Matlab

i and j are very popular variable names (see e.g., this question and this one). For example, in loops: for i=1:10, % do something... end As indices into matrix: mat( i, j ) = 4; Why ...
46
votes
9answers
31k views

What is the difference between an int and a long in C++?

Correct me if I am wrong, int is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31) long is 4 bytes, with a range of values from -2,147,483,648 to 2,147,483,647 (2^31) What ...
7
votes
6answers
7k views

How to include a PHP variable inside a MySQL insert statement

I'm trying to insert values in the contents table. It works fine if I do not have a PHP variable inside VALUES. When I put the variable $type inside VALUES then this doesn't work. What am I doing ...
98
votes
11answers
31k views

Pointer vs. Reference

What would be better practice when giving a function the original variable to work with: unsigned long x = 4; void func1(unsigned long& val) { val = 5; } func(x); or: void func2(unsigned ...
10
votes
6answers
43k views

non-static variable cannot be referenced from a static context

I was taught poorly at first and so I still don't understand everything about static. My error is with every single variable that I declare then try to use later inside my methods I get the ...
85
votes
17answers
33k views

Difference between declaring variables before or in loop?

I have always wondered if, in general, declaring a throw-away variable before a loop, as opposed to repeatedly inside the loop, makes any (performance) difference? A (quite pointless example) in ...
49
votes
7answers
22k views

Is it better in C++ to pass by value or pass by constant reference?

Is it better in C++ to pass by value or pass by constant reference? I am wondering which is better practice. I realize that pass by constant reference should provide for better performance in the ...
18
votes
8answers
3k views

What's the point of the var keyword?

The var keyword does away with the need for an explicit type declaration and I have read with interest the SO discussion of when it might be appropriate. I have also read about (but not used) Boo ...
6
votes
3answers
8k views

“BigInt” in C?

What is the easiest way to handle huge numbers in C? I need to store values in the Area 1000^900... Does anybody know of an easy way to do that? Any help would really be appreciated!
87
votes
9answers
88k views

Objective C Static Class Level variables

I have a class Film, each of which stores a unique ID. In C#, Java etc I can define a static int currentID and each time i set the ID i can increase the currentID and the change occurs at the class ...
68
votes
7answers
21k views

Python variable scope question

I've been programming for many years, and recently started learning Python. The following code works as expected in both python 2.5 and 3.0 (on OS X if that matters): a, b, c = (1, 2, 3) print(a, b, ...
23
votes
5answers
75k views

PHP Pass variable to next page

it seems pretty simple but I can't find a good way to do it. Say in the first page I create a variable $myVariable = "Some text"; And the form's action for that page is "Page2.php". So in ...

1 2 3 4 5 85
15 30 50 per page