Lecture 8: PHP Variables
Think of a variable as a bucket. Literally, a bucket. That bucket can hold stuff in it — like food, or dirt. In PHP, variables are buckets, but instead of holding food or dirt, they hold information — like numbers, text, images, or logic! All you need to know at this point is that variables are buckets that store information for later use. We’ll get to how we actually use the variables in an upcoming lecture.
The basic syntax of a variable is a dollar sign ($) directly followed by a variable name (using text, with no spaces), then an equal sign, followed by the contents of the variable, ending with a semi-colon. Ex: $variable_name = ‘my first variable’;
There are 4 basic variable types, and each type of variable (or “bucket”) is meant to hold specific information. Watch the lecture or download the PDF to learn what the 4 basic variable types are.