PHP syntax: variable assignments

Contributor Icon Contributed by qmchenry Date Icon December 27, 2003  
Tag Icon Tagged: PHP programming

To assign the value “Tolkien” to the variable $author:

$author = "Tolkien";

Once assigned, additional strings can be added to a variable using the dot operator:

$author .= ", J.R.R.";
// results in $author containing "Tolkien, J.R.R."

The dot operator is like an addition operator for strings:

$var = "The author is ".$author;
// $var would contain "The author is Tolkien, J.R.R."

Previous recipe | Next recipe |
 
blog comments powered by Disqus