<? // this example is about double$ or more
$bye=astalavista;
$d=bye;
print $$d;
/*you will see astalavista on browser
because $$d=${$d}=$bye=astalavista
*/
?>
<br />
<? //this is another example it follows reverse...
$tic=tac;
$$tic=tictac;
print $tac;
//tictac=$$tic=${$tic}=$tac
//You will see tictac on your browser.
?>
Here explained double $ string....
Showing posts with label variable. Show all posts
Showing posts with label variable. Show all posts
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......
<? $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......
Subscribe to:
Posts (Atom)