Welcome Guest, Not a member yet? Register   Sign In
Execute Function inside Model by using String Name
#1

[eluser]harman[/eluser]
hi everyBody
i have a question,
Can i call method by string Name, use string as object

Code:
//Current Controller Name
$this->controller_name = $this->router->fetch_directory().$this->router->fetch_class();

//Load Model Same With PostFix "_mod";
$this->load->model($this->controller_name.'_mod');


$ModName=$this->controller_name.'_mod';

//Here is My Problem  $ModName is a string i want use as object name can anybody help me
$this->$ModName->myFunc();
#2

[eluser]danmontgomery[/eluser]
Have you
tried it?

Code:
$model = get_class($this).'_mod';
$this->load->model($model);
$this->$model->myFunc();
#3

[eluser]harman[/eluser]
Thank You Very Much ***** :-) noctrum*****

You Point Out My Mistake

here is My Correct Code.

Code:
$model = get_class($this).'_mod';
$this->load->model("admin/".$model);
$this->$model->myFunc();




Theme © iAndrew 2016 - Forum software by © MyBB