CodeIgniter Forums

Full Version: Simple text being outputted twice
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
Hey All,

I am an extreme CI newbie, as I just started programming with it a little over 15 minutes ago. However, I have set up this very simple application and I see the output being outputted twice.

My very simple controller:

Code:
class Index extends Controller {
    function index() {
        echo "Hey World!";
    }
}

I was wondering if there was anyone who could help me?

Thanks

El Forum

[eluser]nirbhab[/eluser]
Change the class name and function name, as class name is index, the default function is index, and it becomes the constructor too, that's why you are getting the output 2 times.
Code:
class ClassNameOtherThanAnyFunctionInClass extends Controller {
       function __construct()
       {
            parent::Controller();
       }
    function index()
    {
        echo 'Hello World!';
    }

    function comments()
    {
        echo 'Look at this!';
    }
}
ClassNameOtherThanAnyFunctionInClass() PHP4 constructor
__construct() PHP5 constructor

El Forum

[eluser]Unknown[/eluser]
Thank you very much, worked a charm!