gpt4 book ai didi

php - 从模型实例 YII 获取模型名称

转载 作者:可可西里 更新时间:2023-10-31 23:02:32 24 4
gpt4 key购买 nike

如何从模型实例中获取模型名称。例如

$model=新状态;

在这里,状态是模型$model 是状态模型实例。

我想从 $model 即模型实例中获取模型名称即 State。

最佳答案

将此方法添加到您的状态类

public function getModelName()
{
return __CLASS__;
}

并这样调用它:

$model = new State();
echo $model->getModelName();

关于php - 从模型实例 YII 获取模型名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2825131/

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