Welcome Guest, Not a member yet? Register   Sign In
controller in CI - 2.0?
#1

[eluser]anna16[/eluser]
Hi guys

I'm really new to CI 2.0

Okay i noticed that when you define a class model you do it like the code below,
Code:
class Blog_model extends CI_Model

I just want to know if this is also apply in the controller class,
like the codes below,
Code:
class membership extends CI_Controller

Please correct me if I'm wrong.

Thank in advanced.
#2

[eluser]InsiteFX[/eluser]
Hi anna,

Yes, that is the correct way to do it.

Your Controller will look like this:
Code:
class Blog extends CI_Controller {

    function index()
    {
        echo 'Hello World!';
    }

    function comments()
    {
        echo 'Look at this!';
    }
}

InsiteFX
#3

[eluser]stormbytes[/eluser]
Dont forget that (with Controllers) constructors look like this:

Code:
function __construct()
{
    parent:: __construct();
}

If you're dabbling in Ci2, which very much RocKs btw... You probably want to read Phil Sturgeon's post on migrating to Ci2.

It can be had here:

http://philsturgeon.co.uk/news/2010/05/u...gniter-2.0
#4

[eluser]anna16[/eluser]
thanks guys




Theme © iAndrew 2016 - Forum software by © MyBB