action with the same name as the controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: action with the same name as the controller (/showthread.php?tid=43640) |
action with the same name as the controller - El Forum - 07-19-2011 [eluser]tomas[/eluser] If I create a new controller, let's say Test and then add index and test actions, going to index.php/test/test executes the index action instead of the test action Code: class Test extends CI_Controller { navigating to Code: index.php/test/test action with the same name as the controller - El Forum - 07-19-2011 [eluser]Unknown[/eluser] I have no solution for you but I just want to warn you. Depending on your php version, a method with the same name as the classname can become the constructor of this class. There's few lines hidden in the middle of nowhere about that in the php manual. So I think it can be a bit dangerous doing things like this. It's just my opinion... Perhaps you really need to do that ! action with the same name as the controller - El Forum - 07-19-2011 [eluser]pornnarnold[/eluser] [quote author="Pexirouque" date="1311088447"]I have no solution for you but I just want to warn you. Depending on your php version, a method with the same name as the classname can become the constructor of this class. There's few lines hidden in the middle of nowhere about that in the php manual. So I think it can be a bit dangerous doing things like this. It's just my opinion... Perhaps you really need to do that ![/quote] Pretty much as above. I would probably suggest renaming the method to something else and creating a route to access the method at that address. I would assume that is possible. action with the same name as the controller - El Forum - 07-19-2011 [eluser]Aken[/eluser] It's confusing to have redundant information in the URL structure, anyway. I would avoid it all together. |