duanputian5341 2013-10-29 20:25
浏览 15
已采纳

我的逻辑怎么了? [关闭]

I have put together this simple logic to add two numbers, echo the values for a and b then show the answer, it's pretty late here but i cant understand why the answer is NOT the sum of $a + $b. I thought this was ABC stuff but a little help would not go a miss. Thank you in advance.

$number_one = mt_rand(1,100);
$number_two = mt_rand(1,100);

function add_numbers($a, $b) 
{
$sum = $a + $b; 
return $sum;
}

echo "What is " . $number_two . " + " . $number_two . "? <br />";
$answer = add_numbers($number_one, $number_two);
echo $answer;
  • 写回答

1条回答 默认 最新

  • 普通网友 2013-10-29 20:28
    关注

    Because you have a typo...

    echo "What is " . $number_two . " + " . $number_two . "? <br />";
    

    Should be:

    echo "What is " . $number_one . " + " . $number_two . "? <br />";
                              ^^^
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致