什么时候会在PHP中抛出一个DomainException? [英] When would you throw a DomainException in PHP?

查看:733
本文介绍了什么时候会在PHP中抛出一个DomainException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览PHP中预定义的异常列表,我注意到 DomainException 。任何人知道DomainException是什么意思?这是否意味着失败的数据模型验证?

解决方案

这里有一个非常有趣的讨论,关于没有人似乎知道是什么意思:



http:// bugs .php.net / bug.php?id = 47097



从该链接的末尾:


域名是指数据域。那就是
a当$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $例如:




  • 0不在分区的域中。

  • Foo不在域中在
    / b> b

    第一个不同于
    范围和一样,但您可以使用
    InvalidParameter 如果它是
    实际上是执行除法的函数
    的参数。如果是执行分区之前在函数
    中计算的
    值,则
    ,则条件前检查将抛出
    ,而不是执行除法,
    成为 DomainException



I was going through the list of predefined Exceptions in PHP and I noticed the DomainException. Anyone know what does DomainException mean? Does it mean failed data model validation?

解决方案

There's a pretty hilarious discussion here about how no one seems to know what is means:

http://bugs.php.net/bug.php?id=47097

From the end of that link:

Domain means data domain here. That is a DomainException shall be thrown whenever a value does not adhere to a defined valid data domain. Examples:

  • 0 is not in the domain for division.
  • Foo is not in the domain for weekdays.

The first is different from out of range and alike, but you could use InvalidParameter in case it is actually a parameter to the function that performs the division. If it is a value calculated inside the function prior to executing the division and then a pre-conditon check throws instead of executing the division, then it becomes a DomainException.

这篇关于什么时候会在PHP中抛出一个DomainException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆