Re: [PHP] Problem with variables

[email protected] (Tamara Temple)
Newsgroups php.general
Message-ID <[email protected]>
Fernando A <[email protected]> wrote:
> I am working with php and codeigniter, but I have not yet experienced.
> I need create a variable that is available throughout  system.
> This variable contains the number of company and can change.
> as I can handle this?

Hi, Fernando, welcome. I'm just a little unsure what you mean by "number
of company" -- is this a count, as in 10 companies, or is it a phone
number, or is it something else?

Jim's reply is workable -- storing session values is quite useful, but
sessions are tied to a specific browser client/ip, and I'm not sure
that's what you want/need here.

If you are looking for setting a global variable that will be available
everywhere in your application, you can use $GLOBALS, or set it from the
very top level context of the application. Given you're using
CodeIgniter, which sadly I am not versed in, you may need to set it with
$GLOBALS: 

$GLOBALS['my_var'] = 10; // whatever you need to do here

When you say it changes, how and when exactly does it change?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.