PHP syntax: variable assignments

Contributor Icon Contributed by qmchenry  
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."

 

No Comments -


No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment -