实例代码:
<!doctype html>
<html>
<head>
<meta charset ="utf-8">
<title>php字符串运算符</title>
<style>
table, td,th {
border:1px solid black;
}
th{
background-color:#ADD8E6;
}
</style>
</head>
<body>
<h1>php字符串运算符</h1>
<table>
<tr>
<th>运算符</th>
<th>名称</th>
<th>例子</th>
<th>结果</th>
</tr>
<tr>
<td>.</td>
<td>串接</td>
<td>$txt1 = "Hello" $txt2 = $txt1 . " world!"</td>
<td>现在 $txt2 包含 "Hello world!"</td>
</tr>
<tr>
<td>.=</td>
<td>串接赋值</td>
<td>$txt1 = "Hello" $txt1 .= " world!"</td>
<td>现在 $txt1 包含 "Hello world!"</td>
</tr>
</table>
<h3>输出实例</h3>
Hello world!<br>Hello world </body>
</html>
评论