0

我的 php 类中有以下代码,称为 Plaint:

class Plaint extends CAction
{
    public function run()
    {
        $model = new PlaintForm();
        $this->runTests($model);
        ...........

如果从这个 url 输入,我需要在没有 ($this->runTests($model)) 的情况下运行这个类/plaint。如果我从其他 url 进入这个页面,我需要运行 $this->runTests($model);.(eg /filled)。我该怎么做?

4

1 回答 1

0

您可以在当前 url 中查找特定短语:

if(strpos(Yii::app()->request->requestUri, '/filled') !== false) {
    $this->runTests($model);
}

我建议不要将测试代码放入生产代码中。

于 2017-01-18T07:04:14.013 回答