Friday, February 11, 2011

working with variables

I think you have seen a word with dollar sign in php  scripts...... They are variables.. I will explain them in this and future posts... So let's create a new file in phppp directory give it a name index2.php or what ever you want and add this codes (please read comments) :
<? $a=11; $b=22; ?>
<? print $a; ?> <br />  <? print $b; ?> <br />
<? print $a."<br />".$b; ?> <br /> //this line is the same with second line   . (dot) is a concatenation operator
<? print ($a."<br />".$b); ?> <br /> //you can save your lines with concatenation operator,
<? print "$a+$b="; print $a+$b; ?> //the output of this line 11+22=33 you can use html tags inside of " " ,

//i advise to use short html tags in "", for multiple-lined html codes i advise to close php script line (?>)
//then write html code and then open new php script line (<?)
save it and browse and take a look to source code......

No comments:

Post a Comment