Written by Chris Walker
There are some rules to naming variables…
- Variables need unique names to prevent their values from changing through carelessness
- Descriptive names are important. It’s terrible to find out your program depends on a variable called “things.” It doesn’t tell you what it is for or why you need it.
- Uppercase letters can appear anywhere in a variable
- Lowercase letters also are acceptable anywhere
- Underscores work. They are often used to separate words
- Dollar signs are often used at the beginning of variables but they rarely appear anywhere else. They can appear anywhere.
- Numbers may appear anywhere but the beginning.
- Keep consistent in how you name variables. Do not use underscores to divide words and then use camel case later. Pick a format and stick with it.
Variables are one of those things you’ll use a lot in programming when you need to hold a value somewhere. You can use user names to hold an array with all the info about that user. You can use it to store form data. You can use it to keep a running total in a shopping cart. This is a pretty basic tutorial, but hopefully it will lead to many wonderful uses. Thanks for watching!
Go To An Older Location
Go To A Newer Location