Dynamic constants in PHP?

前端 未结 4 2201
迷失自我
迷失自我 2021-02-09 08:36

Is there a way to create a class\'s constants dynamically? I know this sounds a bit odd but let me explain what I\'m trying to do:

  • I have a Enum class who\'s attri
4条回答
  •  一生所求
    2021-02-09 09:06

    I do not recommend it, but eval() ... please don't.

    I've modified autoloaders to automatically define Exception types that are missing or misspelled. Reason: You can catch an uncaught exception, but you cannot recover from the PHP_FATAL when instantiating a typo in your exception class.

提交回复
热议问题