Welcome Guest, Not a member yet? Register   Sign In
HELP! regarding variable scope in a library I created
#4

[eluser]steveh[/eluser]
Thanks for the replies thus far.

noctrum -- Thanks very much for taking the time to provide some sample code... I had already done what you indicated... however, my understanding of "$this->load->library('llib');" is that it would need to be done in each controller/view. I'd done the autoload to ensure the Llib was available without needing specific loading per controller/view. Am I right in thinking I can autoload it? and that your example requires loading per controller/view? Also, in your example, what is the magic of referring to $this->myArray[...] as I'd have thought that myArray is already scoped local to Llib? or am I expecting too much here? or is '$this->" just a very explicit way of referring to something scoped in the embodying class? (is $this explicitly documented somewhere?) arrrgh!
(and also as I understand it, I need to do some other scoping stuff in my Llib to access CI libraries, per: "$CI =& get_instance();" ... hence my thinking there is various other scoping magic that I can't discern from generic documentation.)

InsiteFX -- I'd noticed the Global terms... however wasn't sure how they might apply in the context of CI libraries. At face value, it reads as though I should be declaring "var $myArray = array();" outside the class then have a "global $myArray" inside any of the class methods that utilise it?

In any event, is it apparent from what I'd written as to what my underlying issue is, and the (code) solution? to reiterate:
- autoloading
- global scope to that Request to its variables and methods callable from any controller/view during the Request
(- perhaps even callable later from a hook... e.g. to produce hdr/ftr/menu based on context provided by calls made during controller/view processing)

thanks, Steve


Messages In This Thread
HELP! regarding variable scope in a library I created - by El Forum - 04-25-2011, 07:28 AM
HELP! regarding variable scope in a library I created - by El Forum - 04-25-2011, 07:38 AM
HELP! regarding variable scope in a library I created - by El Forum - 04-25-2011, 10:04 AM
HELP! regarding variable scope in a library I created - by El Forum - 04-25-2011, 07:17 PM
HELP! regarding variable scope in a library I created - by El Forum - 04-25-2011, 08:47 PM
HELP! regarding variable scope in a library I created - by El Forum - 04-26-2011, 04:21 AM
HELP! regarding variable scope in a library I created - by El Forum - 04-26-2011, 06:05 AM
HELP! regarding variable scope in a library I created - by El Forum - 04-26-2011, 07:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB