Welcome Guest, Not a member yet? Register   Sign In
Simple text being outputted twice
#1

[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
#2

[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
#3

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




Theme © iAndrew 2016 - Forum software by © MyBB