- What is a variable:
Variables are like containers.
Elements used to store data
Use that data with Variable name
Open a blank code editor
Open doc type HTML
Open and close PHP tag <?php ?>
Used the $ sign followed by the name of the variable and then ;
$name = ‘Ratan’; for numbers $numbers = 100;
- How can we use the variable?
- echo $name;
- Variables are case sensitive and will end up making them a different variable if different case.
- Data in variable – We can store many different data types
- String data type – Always in quotes (texts)
- Numbers – Does not have quotes
- Floating point numbers – ones with decimals. (takes more memory)
- Concatenation – . Dot between two variables will smash them together
- Assign HTML tag to a variable = $name = “<h1> HELLO</h1>”
- Imp: Can only assign one value to the variables.