0
I am building an application that from the information the user sends me on a GET I will run a function. EX:
//classe
class Page extends CI_Controller {
public class index($param){
//aqui estou procurando algo semelhante a $this->"$param"();
}
private class foo(){ echo 'foo'; }
private class bar(){ echo 'bar'; }
}
For the above example, if my user sent to the function index('foo')
he would have to perform the function $this->foo()
. Could someone show me how I can do my job index()
perform another function depending on the sent parameter?
You need to create routes to your application, the controller should not be responsible for directing actions other than redirects in isolated cases. Here’s an example: http://laravel.com/docs/5.1/routing - It’s a bit boring to do without a framework, but it’s possible, I have a route system that I made for my own use and works as well as frameworks.
– Renan Cavalieri