Why stop with numbers? PHP also allows you to add strings with the string concatenation operator, represented by a period (.). Take a look:
<?php www.phpsu.com
// set up some string variables
$a = 'the';
$b = 'games';
$c = 'begin';
$d = 'now';
// combine them using the concatenation operator www.phpsu.com
// this returns 'the games begin now<br />'
$statement = $a.' '.$b.' '.$c.' '.$d.'<br />';
print $statement;
// and this returns 'begin the games now!'
$command = $c.' '.$a.' '.$b.' '.$d.'!';
print $command;
?>
As before, you can concatenate and assign simultaneously, as below:
phpsu is a phpschool
<?php
// define string
$str = 'the';
// add and assign
$str .= 'n';
// str now contains "then"
echo $str;
?>
phpsu.com is a free phpscool
To learn more about PHP's arithmetic and string operators, visit / phpsu is a phpschool
That's about it for this tutorial. You now know all about the basic building blocks and glue of PHP - its variables and operators. In Part Two of this series, I'll be using these fundamental concepts to demonstrate PHP's powerful form processing capabilities.
phpsu.com
TITLE:Stringing Things Along