PHP - 遇到的Bug - 总结

BUG记录1

问题\] 除数为0,不符合规则 \[问题描述

php 复制代码
// 报错信息
DivisionByZeroError:is thrown when an attempt is made to divide a number by zero.

// example
public 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

问题\] 参数不符合 \[问题描述

php 复制代码
参数要求是数组,实际却是字符串
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://www.drupal.org/project/drupal/issues/3310364) *** ** * ** ***

相关推荐
tryqaaa_4 小时前
md5和sha1常见绕过【详细附新生赛题目】
web安全·php·web
草明5 小时前
android 蓝牙连接-兼容旧版本
android
鹏多多.5 小时前
Flutter使用screenshot进行截屏和截长图以及分享保存的全流程指南
android·前端·flutter·ios·前端框架
青主创享阁6 小时前
玄晶引擎2.7.8更新解析:全新UI+Sora接入,功能优化与Bug修复全汇总
人工智能·bug
ShoreKiten7 小时前
第三届SHCTF--EZphp
web安全·php·php反序列化
在坚持一下我可没意见7 小时前
软件测试入门复习笔记:BUG篇
笔记·bug·测试
Flywith248 小时前
【每日一技】Warp Workflow 使用示例
android·前端
冬奇Lab8 小时前
JobScheduler与WorkManager:任务调度机制
android·源码阅读
Zwj-c9 小时前
【测试报告】个人博客系统测试报告(功能测试、自动化测试、Bug描述)
功能测试·selenium·测试用例·bug