I have these URLs:
How to get controller name, action name from these URLs. I'm CodeIgniter newbie. Are there any helper function to get this info
Ex:
$params = helper_function( current_url() )
Where $params
becomes something like
array (
'controller' => 'system/settings',
'action' => 'edit',
'...'=>'...'
)
If you using $this->uri->segment , if urls rewriting rules change, segments name matching will be lost.
// fecth class the class in controller $this->router->fetch_method();
// method
Instead of using URI segments you should do this:
That way you know you are always using the correct values even if you are behind a routed URL, in a sub-domain, etc.
Update
The answer was added was in 2015 and the following methods are deprecated now
Hi you should use the following approach
for this purpose but for using this you need to extend your hook from the
CI_Controller
and it works like a charm, you should not use uri segmentsAs an addition
You could use the URI Class:
I've also been told that the following work, but am currently unable to test: