Newbie question - syntax error in Using Yii Events chapter?

Hi,

I was just trying code on the book and I got a syntax error from the following code:




Yii::app()->onBeginRequest = function($event)

{

	return ob_start("ob_gzhandler");

}



Could you please point me towards the solution? The full code is reproduced below.




<?php


// change the following paths if necessary

$yii=dirname(__FILE__).'/../yii/framework/yii.php';

$config=dirname(__FILE__).'/protected/config/main.php';


// remove the following lines when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);

// specify how many levels of call stack should be shown in each log message

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);


require_once($yii);

$app = Yii::createWebApplication($config);


Yii::app()->onBeginRequest = function($event)

{

	return ob_start("ob_gzhandler");

}


Yii::app()->onEndRequest = function($event)

{

	return ob__end_flush();

}


$app->run();



My system:

PHP Version 5.3.6-13ubuntu3.6

Yii 1.1.9


$foo = function bar($param) { /* .. */ }

You can’t do that. It should give an error. Can you link me to where you were instructed to do that?

And are you sure you weren’t instructed to use create_function() instead?

this is attachment of event handler. it is correct.




Yii::app()->onBeginRequest = function($event){

    return ob_start("ob_gzhandler");

};// <<< semicolon



may be you are missing ; at the end? after curly brace ;)

and there are two underscores in second event handler

NOTE: moved to proper section (General Discussion for Yii 1.1.x instead of Feature Requests)

Thanks everybody! The code works with the added semicolons.

One problem - Eclipse 3.7.0 with PDT 2.2.1 still underlines the function declaration and lists it as an error.

Could you please point me to an Yii compliant IDE?

mdomba, sorry for the wrong placement.