gpt4 book ai didi

php - 在 PHP 中抛出 NotImplementedError?

转载 作者:IT王子 更新时间:2023-10-28 23:55:44 26 4
gpt4 key购买 nike

PHP中有一种NotImplementedError吗?

我想将这些添加到一些 stub 方法和接口(interface)中,以警告扩展我的类,它们仍有工作要做。还是在 PHP 中实现的方式不同?

最佳答案

PHP 没有内置的 NotImplementedException 但是欢迎您创建自己的。我想BadMethodCallException接近了,这将是一个不错的扩展候选人

class NotImplementedException extends BadMethodCallException
{}

...在你的方法中

public function notImplementedMethod()
{
throw new NotImplementedException();
}

你也可以很简单地做这样的事情

throw new Exception('Not implemented');

关于php - 在 PHP 中抛出 NotImplementedError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8092886/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com