In this tutorial i will show how to call a method from a class
first we should import the class.
after that we should instantiate the imported class.
then we can call method via instance.
Example,
class AnotherController extends Controller
{
public function __construct($id=NULL)
{
}
public function message()
{
return 'Message from Another Controller';
}
}
?>
Above lines shows a class(Controller). assume that this class is placed in side
the contollers folder.
we want to access method "message" from another controller.
solutioin is ,
public function messageFromAnotherClass()
{
Yii::import("application.controllers.AnotherController");
$another = new AnotherController();
return $message = $another->message();
}
first we should import the class.
after that we should instantiate the imported class.
then we can call method via instance.
Example,
class AnotherController extends Controller
{
public function __construct($id=NULL)
{
}
public function message()
{
return 'Message from Another Controller';
}
}
?>
Above lines shows a class(Controller). assume that this class is placed in side
the contollers folder.
we want to access method "message" from another controller.
solutioin is ,
public function messageFromAnotherClass()
{
Yii::import("application.controllers.AnotherController");
$another = new AnotherController();
return $message = $another->message();
}
ReplyDeleteWonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!
Online Web Development Courses
This comment has been removed by the author.
ReplyDeleteGreat Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
ReplyDeleterpa training in electronic city | rpa training in chennai
rpa online training | selenium training in training
I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favourites blog site list and will be checking back soon.
ReplyDeleteData Science Training in Chennai | Data Science training in anna nagar
Data Science training in chennai | Data science training in Bangalore
Data Science training in marathahalli | Data Science training in btm
Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
ReplyDeletejava training in chennai | java training in bangalore
java training in tambaram | java training in velachery
It was worth visiting your blog and I have bookmarked your blog. Hope to visit again
ReplyDeletepython training Course in chennai
python training in Bangalore
Python training institute in kalyan nagar
Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
ReplyDeleteBest Devops Training in pune
Devops Training in Chennai
Very good information. Its very useful for me. We need learn from real time examples and for this we choose good training institute, we need to learn from experts . So we make use of demo classes . Recently we tried web desining demo class of Apponix Technologies.
ReplyDelete