PHPsu
MANUAL ZH  |  EN
     


Current Position :| index>Beginners> Stringing Things Along

Stringing Things Along

FROM: AUTHOR: TIME:2008-05-31 HITS:

Why stop with numbers? PHP also allows you to add strings with the string concatenation operator, represented by a period (.). Take a look:

phpsu is a phpschool

<?php

// 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;

phpsu.com

// and this returns 'begin the games now!'
$command = $c.' '.$a.' '.$b.' '.$d.'!';
print
$command;
phpsu.com


?>
www.phpsu.com

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
Copyright 2008 The PHPsu All rights reserved. This mirror generously provided by: .Hp Inc.
Last updated: Fri Jun 6 22:59:01 GMT-8 2008