PhP Variables
Ok guys, today I'm going to attempt to throughly explain to you what variables are used for in PHP.
Variables are basically a storage, you can use them to store a string of text or anything else you'd life pratically.
A example of a variable storing a string of text:
PHP Code:
- Code:
-
<?PHP
$text = "I am storing text";
?>
To display the text on the site you'd call the variable out.
Example:
PHP Code:
- Code:
-
<?php
$text = "I am storing text";
echo $text
?>
How to store a integer you ask? Well here you are!
PHP Code:
- Code:
-
<?PHP
$int1 = 9000;
?>
To display this we call it out, like this:
PHP Code:
- Code:
-
<?PHP
echo $int1;
?>
Now before someone judges me and says that the code above is wrong, I want to make it known that a fundamental of php is that the last line of a php code does not require the semicolon at the end.
Anyhow, that is basically how you'd store text in a PHP variable and later call it out, you can change the value of the variable anytime also.
PHP can also hold more than text in variables, such as integers. Integers are basically just numbers. Just as 1,2,3,4,5 and what not.
Another fundamental of PHP is that you don't have to deem your variables string or boolean or int when your creating a variable. Other languages make you do this.
If you require additional information post below.[/center][/i][/b]