Getting Started With Variables
1. PHP Syntax
The PHP script strat with less than and question mark signs (<?) and end with question mark and greater than sign (?>) any code will be written between these tags.
<?
echo "My First Page of PHP";
echo "I am learning PHP";
?>
A variable is a container that stores the information that you want to use on the page for later use. You can save text and numbers in variable. As the name shows it’s a variable so you can change values (text or number) in variable.
Any text with $ sign will become variable in php
<?
$myNum=1;
$myText="This is my first variable text.";
?>
Variables are case sensitive.
3. Joining direct text and variable data
$myText="This is my first variable test.";
$myJoinText=$myText." This is the joing text with variable.";
$myJoinText2="This is Text1."." This is Text2.";
echo $myJoinText;
echo $myJoinText2;
Note
The "." dot sign used to concat the two variables or strings.
To add one number to another, the + symbol is used in PHP. If you see 4 + 3, it means add 3 into 4.
<?
echo 2+2;
$a=4;
$b=3;
echo $a+$b;
$add=$a+$b;
echo "The added values are = ".$add;
?>
To subtract one number from another, the - symbol is used in PHP. If you see 4 - 3, it means subtract 3 from 4.
<?
echo 2-2;
$a=4;
$b=3;
echo $a-$b;
$subtract=$a-$b;
echo "The subtracted values are = ".$subtract;
?>
To multiply two numbers, the * symbol is used in PHP. If you see 4 * 3, it means multiply 3 with 4.
<?
echo 2*2;
$a=4;
$b=3;
echo $a*$b;
$multiply=$a*$b;
echo "The multiplicated values are = ".$multiply;
?>
To divide two numbers, the / symbol is used in PHP. If you see 4 / 2, it means divide 4 by 2.
<?
echo 2/2;
$a=4;
$b=2;
echo $a/$b;
$divide=$a/$b;
echo "The divided values are = ".$divide;
?>
Php Discussion
- - PHP 4 or 5 as a Deploymen
- - How do I decode a html/ph
- - PHP help
- - What is wamp?
- - How to execute a php file
Php Source Code
- - Wraps A String To A Given
number Of Characters Using A
string Break Character - - Uppercase The First Character
of Each Word In A String - - Make A String's First Character
uppercase - - Strip Whitespace (or Other
characters) From The Beginning
and End Of A String - - Return Part Of A String



