Lesson 3: Operators in PHP

There are four basic operators in PHP.

1.Arithmetic operators    +    -   *    %.
2.Logical operator         &&   ||    !
3.Conditional operator   (exp1) ? exp2 : exp3.
4.Unary operator        ++/-- (pre/post)

these operator are very useful and used frequently in  programming.

comment style in PHP :- 
1. simple style for single line comment
   //write your comment
2. multi line comment   for large documentation
   /*this blog is for those who want to learn PHP for free*/

Generating output in PHP : - 
a simple PHP program :-
<title>My first PHP programming.</title>
<?php  //opening tag

 echo "My first PHP programming!";

 ?> // closing tag
Output : My first PHP programming!

the above program simply embed a small PHP code echo "My first PHP programming!";
we use either echo or print for output something from PHP code as we have done above.

for outputting a variable , e.g.
$var = "My first PHP programming!";
echo $var;

simply output My first PHP programming!

string concatenation in PHP : - 
use dot(.) to concatenate to strings , e.g.
echo "My"."Blog";

would output :- My Blog

Previous Post Next Post