PHP 程序中两个字符串的连接
phpserver side programmingprogramming
在 PHP 中连接两个字符串,代码如下 −
示例
<?php $a = 1.967; $b = 1.969; $res = $a." and ".$b; echo " $res
"; if((round($a, 2)) == (round($b, 2))) { echo "
两个值相等!"; } else { echo "
两个值不相等"; } ?>
输出
这将产生以下输出−
1.967 and 1.969 两个值相等!
示例
现在让我们看另一个例子 −
<?php $val1 = 'Jack'; $val2 = 'Sparrow'; echo "First Name = $val1
"; echo "Second Name = $val2
"; $res = $val1.$val2; echo "Concatenation = $res
"; ?>
输出
这将产生以下输出−
First Name = Jack Second Name = Sparrow Concatenation = JackSparrow