単にアプリケーションを終了するだけです。それがPHPのexit()
と異なる点は、終了する前にonEndRequest()
を呼び出すことです。
ドキュメントでは、status
パラメータ0は通常の終了を意味し、他の値は異常終了を意味しますが、そのようには実行されません。 status
パラメータは単にexit()
関数に渡されます(これはもちろん出力されます)。
Yii::app()->end(json_encode($data), true);
注:
Yii::app()->end('saved', true);
さえオブジェクトは以下のように出力することができる(1)onEndRequest()
は、アプリケーションが要求を処理した直後に上昇します。この機能を使用して、ログやその他の便利な機能をプロンプトすることができます。
Yii Documentation of end()
/**
* Terminates the application.
* This method replaces PHP's exit() function by calling
* {@link onEndRequest} before exiting.
* @param integer $status exit status (value 0 means normal exit while other values mean abnormal exit).
* @param boolean $exit whether to exit the current request. This parameter has been available since version 1.1.5.
* It defaults to true, meaning the PHP's exit() function will be called at the end of this method.
*/
public function end($status=0,$exit=true)
{
if($this->hasEventHandler('onEndRequest'))
$this->onEndRequest(new CEvent($this));
if($exit)
exit($status);
}
これが助けた場合、私は投票をいただければと思います。ありがとう! – acorncom
ええと、受け入れられた答えにしてください。それはあなたの評判と私の助けになります。どうも! – acorncom