PHP offers different kinds of operators having distinctive functionalities. Operators enable us to perform arithmetic activities, string concatenation, compare values and to perform boo perations, artic, per perations, to perform the perations, article per perations, performer per perations will learn string operators given by PHP. Let's first learn the types of string operators in php. There are two string operators provided by PHP.
1.Concatenation Operator ("."# # This operator combines two string values and returns it as a new string.
2.Concatenating Assignment operator (".="):
Š This operation atta the argument
# side on the left side. Let's demonstrate the utility of the above operators by following examples.Example:<?php $a = 'Good'; $b = 'Morning'; $c = $a.$b; echo " $c "; ?>
Goodmorning
<?php $a = 'Hello'; $b = [" Good morning"," Folks"]; for($i = count($b)-1; $i >= 0;$i--) { $a .= $b[$i]; } echo " $a"; ?>
Hello Folks Good morning
<?php $val = 5; echo "Result: " . $val + 5; ?>
5
<?php $var = 5; echo "Result: " . ($var + 5); ?>
Result:10
以上是在PHP中拼接兩個字串的詳細內容。更多資訊請關注PHP中文網其他相關文章!