相关疑难解决方法(0)

检查未定义的对象属性时,组合isset和is_null会失败

我正在尝试将一个功能组合在一起isset,is_null以便于使用

我的方法:

class sys {

  public static function is_null(&$variable) {

    // if it's not set
    if (!isset($variable)) {
      return true;
    }

    // if array
    if (is_array($variable)) {
      return (boolean) (count($variable) < 1);
    }

    // if string
    return (boolean) (strlen($variable) < 1);
  }

}
Run Code Online (Sandbox Code Playgroud)

我在一个对象中使用它时遇到的问题是以下异常:

ErrorException [注意]:间接修改重载属性xxx无效.

php exception

0
推荐指数
1
解决办法
405
查看次数

标签 统计

exception ×1

php ×1