In Computer programming the variable are that memory location where the constant values are store. You can store your values on that memory location for the purpose of further manipulation in your program.
for example
marks
you can also assign the value like :
marks=200
In PHP programming we must care of two thing. First variable must be declare with $ dollar sign at the beginning.
For example:
$marks = 200
Second thing as a semi-colon ( ; ) at the end of the statement.
$marks = 200;
If you get some error then first check the semi-colon at the end of statement. The next thing to check dollar sign before the variable name.
You can also assign the text value to your variables. For example Name or Address or anything in text format .
$name = "Tanvir";
When you assign the text value the this text must be enclose in double quotes or in single quotes.
$name = " Tauqeer "; or $name = ' Tauqeer ';
Don't use quotes like this:
$name = ' Tauqeer ";
First of all installed Wampserver. This will create server on your PC and you will run PHP code. You can also install XAMPP software. which run the Apache server and SQL server. So that you can test your PHP code with SQL connection.
Now we take an complete example of PHP variable
Variable Practice File
After typing this test code in any text editor for example in Notepad in window then save the page as variables.php in C:\xampp\htdocs.
Now Then Run this script by typing the following line in your browser.
http://localhost/variables.php
Now we little describe the Above Code. PHP code is always written in between <?php and ?>
echo statement is used to display anything on the page. You can also use print command for this purpose for example:
print ($name) ;
Variables in PHP
PHP Concatenation
Calculation in PHP
If Statements in PHP
if ... else Statements in PHP
Nested IF Structure in PHP
PHP Comparison Operators
Switch Statement in PHP
Logical Operators In PHP
PHP Booleans
FOR Loop in PHP
While Loop In PHP
foreach Loop In PHP
Break Statement
Array In PHP
Associative Array
The Count function
Changing Case Function
Trim Function In PHP
Str_shuffle( ) function
strpos function in PHP
Explode() Function in PHP
Function
Passing Function Arguments
Server Variables
Header Function
Include Function
The require Function