ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to declear global variable in Controller?

June 22, 2009 10:49pm

Subscribe [2]
  • #1 / Jun 22, 2009 10:49pm

    PEN Vannak

    14 posts

    Dear CodIgnitor members,

    I have the problem with CodeIgnitor when I want to declear the variable in the class controller.
    Could you explain me?

  • #2 / Jun 22, 2009 10:53pm

    Thorpe Obazee

    1138 posts

    Dear CodIgnitor members,

    I have the problem with CodeIgnitor when I want to declear the variable in the class controller.
    Could you explain me?

    what do you mean by declear?

  • #3 / Jun 22, 2009 10:54pm

    tonanbarbarian

    650 posts

    since every request in CI revolves around a single controller, rather than creating a global variable you can simply just create a property of the controller

    i.e. if previously you wanted to create a global variable like this

    global $myvar;
    $myvar = 'abc';

    try doing this instead

    $this->myvar = 'abc';

    Then if you want to access this in the model, libraries etc

    $CI =& get_instance();
    echo $CI->myvar;
  • #4 / Jun 22, 2009 10:55pm

    Thorpe Obazee

    1138 posts

    Dear CodIgnitor members,

    I have the problem with CodeIgnitor when I want to declear the variable in the class controller.
    Could you explain me?

    what do you mean by declear?

    so it’s declare. I was leaning to the ‘opposite of clear’ option 😛

  • #5 / Jun 23, 2009 12:30am

    Colin Williams

    2601 posts

    Dear CodIgnitor members,

    I have the problem with CodeIgnitor when I want to declear the variable in the class controller.
    Could you explain me?

    what do you mean by declear?

    so it’s declare. I was leaning to the ‘opposite of clear’ option 😛

    We are also “CodIgnitors” so we must be setting fish on fire…

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases