What are Variables ? A variable is best thought of as a container for data. Once data has been stored in a variable (or, put differently, once a variable has been assigned a value), that data/variable can be altered , printed to the Web browser (when I say printed, it may help to think of it as sent, but it's the print statement that does the sending, so either term is appropriate), saved to a database, e-mailed, and so forth. Variables are, by their nature, flexible: you can put data into a variable, retrieve that data from it (without affecting the value of the variable itself), put new data in, and you can continue this cycle as long as is necessary. But, variables in PHP are also temporary: they only exist ”that is, they only have a value ”while they are used within a script. Once you are in a new page, those variables cease to exist, unless you pass them along to the new page, which I'll discuss in the next chapter (HTML Forms and PHP). |