All Questions

818
votes
23answers
1212419 views

PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"

I am running a PHP script, and keep getting errors like: Notice: Undefined variable: my_variable_name in C:\wamp\www\mypath\index.php on line 10 Notice: Undefined index: my_index C:\wamp\www\...
7661
votes
88answers
1168136 views

How do JavaScript closures work?

How would you explain JavaScript closures to someone with a knowledge of the concepts they consist of (for example functions, variables and the like), but does not understand closures themselves? I h...
1588
votes
24answers
408301 views

What is the scope of variables in JavaScript?

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 glob...
183
votes
11answers
406622 views

Non-static variable cannot be referenced from a static context

I've written this test code: class MyProgram { int count = 0; public static void main(String[] args) { System.out.println(count); } } But it gives the following error: Main...
213
votes
6answers
75179 views

Using a variable for a key in a JavaScript object literal

Why does the following work? <something>.stop().animate( { 'top' : 10 }, 10 ); Whereas this doesn't work: var thetop = 'top'; <something>.stop().animate( { thetop : 10 }, 10 );...
112
votes
9answers
15558 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 shoul...
99
votes
12answers
358926 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 ...
68
votes
8answers
45611 views

"Variable" variables in Javascript?

I know it's possible in PHP to have "variable" variables. For example $x = "variable"; $$x = "hello, world!"; echo $variable; // displays "hello, world!" Is this possible in javascript? How would...
70
votes
20answers
301440 views

How to combine two strings together in PHP?

I don't actually know how to describe what I wanted but I'll show you: For example: $data1 = "the color is"; $data2 = "red"; What should I do (or process) so $result is the combination of $data1 a...
67
votes
7answers
107099 views

Assigning variables with dynamic names in Java

I'd like to assign a set of variables in java as follows: int n1,n2,n3; for(int i=1;i<4;i++) { n<i> = 5; } How can I achieve this in Java?

Previous Next