“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP

Notice: Undefined variable From the vast wisdom of the PHP Manual: Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major security risk with register_globals turned on. E_NOTICE level error is issued in case of working with uninitialized variables, however not … Read more

What is the naming convention in Python for variable and function names?

See Python PEP 8: Function and Variable Names: Function names should be lowercase, with words separated by underscores as necessary to improve readability. Variable names follow the same convention as function names. mixedCase is allowed only in contexts where that’s already the prevailing style (e.g. threading.py), to retain backwards compatibility.

Define a global variable in a JavaScript function

As the others have said, you can use var at global scope (outside of all functions and modules) to declare a global variable: (Note that that’s only true at global scope. If that code were in a module — <script type=”module”>…</script> — it wouldn’t be at global scope, so that wouldn’t create a global.) Alternatively: In modern environments, you can assign to … Read more

Define a global variable in a JavaScript function

As the others have said, you can use var at global scope (outside of all functions and modules) to declare a global variable: (Note that that’s only true at global scope. If that code were in a module — <script type=”module”>…</script> — it wouldn’t be at global scope, so that wouldn’t create a global.) Alternatively: In modern … Read more

Java: “error: cannot find symbol”

The n variable was declared in the main method and thus is visible only in the main method, nowhere else, and certainly not inside of the calcNumFactors method. To solve this, give your calcNumFactors method an int parameter which would allow calling methods to pass an int, such as n into the method. and call it like so: