网络安全 频道

不开TM 用腾讯QQ也能新建TM企业群(图)

字符串连接符 

    为什么停止数字的介绍呢?PHP也允许你用字符串连接符,它用”.”句号符号表示,对字符串做加法。请看下面的代码:

<?php // set up some string variables $a = 'the'; $b = 'games'; $c = 'begin'; $d = 'now'; // combine them using the concatenation operator // 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; ?>

    和以前一样,你也可以同时连接和赋值,如下所示:

<?php // define string $str = 'the'; // add and assign $str .= 'n'; // str now contains "then" echo $str; ?>

    学习更多关于PHP算术和字符串操作符,请访问:
http://www.php.net/manual/en/language.operators.arithmetic.phphttp://www.php.net/manual/en/language.operators.string.php


    上面就是本次教程的全部了。你现在了解了所有的PHP基本构造块和粘合剂---它的变量和操作符。在这个系列的第二部分,我将会使用这些基础概念显示PHP强大的表单处理能力。

0
相关文章