我无法理解代码的行为:
输入 :
<?php
function polldaddy_choices($choices) {
foreach ($choices as $choice) {
$answer = "<pd:answer>
<pd:text>" . $choice . "</pd:text>
</pd:answer>";
echo $answer;
}
}
$total_choices = array('yes' , 'no' , 'do not know');
$ans = polldaddy_choices($total_choices);
$xml = "world" . $ans . "hello" ;
echo $xml;
?>
输出 :
<pd:answer>
<pd:text></pd:text>
</pd:answer><pd:answer>
<pd:text></pd:text>
</pd:answer><pd:answer>
<pd:text></pd:text>
</pd:answer>worldhello
为什么字符串出现在输出的末尾?
这是键盘上的链接:http: //codepad.org/2dbiCalb