If you did not guess, variables are the most important thing in php and most other programming languages.
I'll be telling you about simple variables and how to use them.
Common variables look like this:
And to define what the variable is you do this:
Code:
$username = "Carnage";
After doing this, php will now recognise "$username" to mean "Carnage". So if you write this afterwards:
Code:
echo "Username: $username";
When uploaded the page will show this:
"Username: Carnage"
Thats basic string variables but you can use number variables too.
Try out this page:
Quote:
<?php
$firstNum = 1;
$secondNum = 3;
$thirdNum = $firstNum + $secondNum;
echo "$firstNum + $secondNum = $thirdNum";
?>
|
This will make "1 + 3 = 4".
To multiply number use * and to divide them use /
Variables are very important, use them wisely, and experiment.
My next tutorial will be on functions, thanks for reading.