我需要知道是否可以连接字符串,如下所示?如果没有,那么还有什么选择呢?
while ($personCount < 10) { $result+= $personCount . "person "; } echo $result;
它应该看起来像1 person 2 person 3人等。
1 person 2 person 3
您不能+在串联中使用符号,那么替代方法是什么?
+
仅.用于连接。而您错过了$personCount增量!
.
$personCount
while ($personCount < 10) { $result .= $personCount . ' people'; $personCount++; } echo $result;