无法弄清楚为什么我的代码不会正确地返回总和,如果它与标签标签连接。 但它可以正常,如果在不同的回声为什么我的代码在连接时会返回错误的总和?
if(isset($_POST['add'])){
if(!empty($_POST['num1'])&&!empty($_POST['num2']))
{
$a = $_POST['num1'];
$b = $_POST['num2'];
//this works
echo '<label id="sumLabel"> sum = ';
echo $a+$b;
echo '</label>';
//this doesnt work
//why wont this code display num of a and b?
//instead it returns just value of b
//isnt my code above just the same as this?
echo '<label id="sumLabel"> sum = ' . $a+$b . '</label>';
}
else {
echo 'PLEASE INPUT num1 num2';
}
}
@JericRodrigoTibayan,检查'concatenation'单词拼写。并阅读更新的答案。 %) – sectus 2014-10-10 05:38:41
谢谢仙人掌。现在我明白这是为什么它不能正常工作。伟大的链接btw ..非常感谢 – 2014-10-10 05:39:45