【发布时间】:2012-02-21 11:15:01
【问题描述】:
为什么下面的代码输出0?
它适用于数字而不是字符串就好了。我在 JavaScript 中有类似的代码也可以工作。 PHP 不喜欢 += 带字符串吗?
<?php
$selectBox = '<select name="number">';
for ($i=1; $i<=100; $i++)
{
$selectBox += '<option value="' . $i . '">' . $i . '</option>';
}
$selectBox += '</select>';
echo $selectBox;
?>
【问题讨论】:
-
这个问题真的是重复的吗?该问题要求在特殊情况下附加一个字符串,并对代码的输出提出更具体的问题。