Welcome Guest, Not a member yet? Register   Sign In
Simple Controler/Class naming problem
#1

[eluser]seismic[/eluser]
Hi there, please help me. I have the problem with the naming:

I have the controler with the name: test.php (in its folder controllers)
Code:
<?php
class Test extends Controller {
function index() {
  echo 'Test CI. This is class Test;
}
}
?>

What we know the naming rule is:
name of the class -> First Letter Uppercase
name of file -> all Lowercase.

Anyway, putting the link: www.example.com/index.php/test <- it doesnt works. Ive tried also www.example.com/test (it opens the main site : www.example.com)

I doesnt works until i change the controller name to Test.php (So first letter uppercase like in the name of class in the file)
then it works with www.example.com/index.php/Test

Of course it doesnt work even the name of class is lowercase: 'class test' -> www.example.com/index.php/test <- this also doesnt works

Does anyone khave the idea where the bug could be located, how to fix this problem?
#2

[eluser]überfuzz[/eluser]
If you're puzzled about how to set up controllers you're really better off checking with the all mighty user_guide. But any way, you need a function named as the controller. Try something like this:
Code:
class Test extends controller
{
   function Test()
   {
      parent::__construct();
   }
    
}

You should be able to reach it like this. www.yoursite.com/test
#3

[eluser]seismic[/eluser]
Thank you. It helps.
i'll take a look to the part about controllers.
#4

[eluser]überfuzz[/eluser]
Do that! The user_guide is often the best place to get issues sorted. There are things missing, but most of the time you'll find what you need to know. If you don't know where to look people here will gladly point you in the right direction.

Welcome to the forum!
#5

[eluser]stuffradio[/eluser]
I find you can also search the wiki for other things or search the forums.




Theme © iAndrew 2016 - Forum software by © MyBB