Global Functions

In yii where we define the global function, which can access anywhere in the entire yii application?

Also need to perform the cache in this functions and call it many events of application and where we define the global data?

you can put it in separate file and include it in index.php or config file so it will be always visible.

from every place in application you can use application object to access components (such cache) or global data:

Yii::app()->params['param'] = 'ddd';


$cachedData = Yii::app()->cache->get( 'id' );

if( $cachedData === false ) {

    $cachedData = ....;

    Yii::app()->cache->set( 'id', $cachedData );


Where i put that file? Give some sample for clear to me.?

where you want… I would put it simply in protected folder.