BUG记录1
[问题] 除数为0,不符合规则
[问题描述]
// 报错信息DivisionByZeroError:is thrown when an attempt is made to divide a number by zero.// examplepublic class Example{ public static void Main() { int number1 = 3000; int number2 = 0; try { Console.WriteLine(number1 / number2); } catch (DivideByZeroException) { Console.WriteLine("Division of {0} by zero.", number1); } }}
[解决方法] 运行前判断 如果除数为0,则不要计算
[链接]
BUG记录2
[问题] 参数不符合
[问题描述]
参数要求是数组,实际却是字符串implode(): Argument #1 ($pieces) must be of type array, string given in implode()// 出错前代码$variables['classes'] = implode(' ', $variables['classes_array']);// 修改方法if(is_array($variables['classes_array'])){$variables['classes'] = implode(' ', $variables['classes_array']);}else if (is_string($variables['classes_array'])){$variables['classes'] = implode(' ', (array)$variables['classes_array']);// 等价于$variables['classes'] = explode(' ', $variables['classes_array']);}
[解决方法] 运行前判断参数类型
[链接] 讲解
来源地址:https://blog.csdn.net/JUN_7777/article/details/133743001