普通网友 2015-09-17 04:37
浏览 24
已采纳

警告:除以错误在php重复[重复]

This question already has an answer here:

I am getting this error in php which i quite don't understand why it is happening. Can anyone shed some light on why this is an error ? I am a beginner in php so please bear with me. Any sort of feedback would be greatly appreciated.

<!DOCTYPE html>
 <head> 

 <title> Distance </title>
   </head>

   <body>

   <?php


 function distance($lat,$lng,$d){

   $distannce = ($lat - $lng) / $d;

   return $distannce;

   }

$stand = distance(isset($_POST['val']),isset($_POST['value']),isset($_POST['dist']));

  ?>
    <form method = "post">



   <input type="checkbox" name="dtLatLng_Lat"  checked="checked"  />
    <label for="dtLatLng_Lat"> Latitude </label>&nbsp &nbsp &nbsp;

  base
  <input type="text"name="val"  size ="6"   style="width:60px"; /> 

    dist
    <input type="text"name="dis" id="dis" size = "1"; /> 
    <label for="dis">  </label>
    <br>

  <input type="checkbox" name="dtLatLng" id="dtLatLng" checked="checked" />
   <label for="dtLatLng"> Longitude </label>&nbsp &nbsp;
   base
   <input type="text" name="value" id="dtvalue" size ="6" style="width:60px";/> 
    <label for="dtvalue"> </label>&nbsp;

dist
   <input type="text"name="dist" id="dtval" size ="1"; /> 

   <br>

     <input type="submit" name="submit" value="Submit" />

    </form>
   </body>
     </html>
</div>
  • 写回答

1条回答 默认 最新

  • dsrbb20862 2015-09-17 04:46
    关注

    In your code $d becomes zero due to this it shows "Warning: Division by zero Error in php duplicate"

    Try this

    function distance($lat,$lng,$d){
    
       if($d != 0)
       {
           $distannce = ($lat - $lng) / $d;
       }
       else
       {
           $distannce = 0;
       }
    
       return $distannce;
    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?