Mycomponent


class Mycomponent extends CComponent

{


public function init()

{

$this->onTestEvent = 'eventHandler';

}


public function onTestEvent(){}


function eventHandler($event)

{

echo "onTestEvent";

}


}


class SiteController extends CController

{

public function actionIndex()

{ 

$event = new CEvent($this);

Yii::app()->mycomponent->raiseEvent('onTestEvent',$event); 

$this->render('index');

}

}

error:

Why?

$this->onTestEvent = array($this,‘eventHandler’);

It is OK! Thank you ,qiang! :smiley: