Should "Index" be avoided as a controller name in CodeIgniter? |
Is it recommended to avoid using "Index" as the name for a controller class in CodeIgniter? I've noticed that when I have an "Index" controller, its methods are called multiple times. Specifically, the index method is always called first, regardless of whether I visit a path that should be routed there.
Here's an example from the code: class Index extends CI_Controller { public function index() { echo "index"; } public function blah() { echo "blah"; } } When I visit "index/blah", I see "indexblah" printed. When I visit "index/index", I see "indexindex". However, if I rename the controller to something else (e.g., "Foo"), the issue doesn't occur. While renaming the controller is a workaround, I'm curious to know why this behavior is happening. Should I report this as a bug to CodeIgniter? (Note: I haven't set up any routes in "configs/routes.php," and my "index.php" is located developer echat outside the CodeIgniter directory.) I appreciate any insights or advice regarding this matter. |
Messages In This Thread |
Should "Index" be avoided as a controller name in CodeIgniter? - by CharlotteFilemdar - 05-30-2023, 02:46 AM
RE: Should "Index" be avoided as a controller name in CodeIgniter? - by InsiteFX - 05-31-2023, 11:31 PM
RE: Should "Index" be avoided as a controller name in CodeIgniter? - by alexwriter - 11-05-2023, 11:58 AM
|