I am using Yii 1.1.12 I have a class something like this:
project_folder/protected/components/myfolder/ClassA.php
class ClassA {
public function getData() {
return 'data';
}
}
How to call getData() of ClassA from controller or from any other Class?
This should work
Yii::import('application.components.myfolder.ClassA');
echo ClassA::getData();
Here example:
// /protected/components/A.php
class A extends CApplicationComponent
{
public function getData()
{
return 'data';
}
}
//main config.
'components' => array(
// ...
'a' => array(
'class' => 'application.components.A'
),
How to use:
echo Yii::app()->a->getData();
die();