Welcome Guest, Not a member yet? Register   Sign In
Global $data array?
#4

[eluser]skunkbad[/eluser]
I've seen where people just added to the application/config/constants.php, but I don't like use that method because there are some default values in there, and to me this stuff ought to be in the system directory. Anyways, to add a constant, you just create another entry:

Code:
define('SOMETHING', array(
  'value',
  'value-two',
  'etc'
));

Then, in the place where you want to use the array, you access it like this:

Code:
var_dump( SOMETHING );

As far as I know the constants defined in application/config/constants.php should be loaded early enough that you could use them anywhere, but if not, then make a pre-init hook and define the array there. I do this in Community Cart, in case you want to see an example. The hook is located at application/hooks/my-site-definitions-hook.php. Community Cart link in my signature.


Messages In This Thread
Global $data array? - by El Forum - 07-03-2011, 06:43 AM
Global $data array? - by El Forum - 07-03-2011, 07:29 AM
Global $data array? - by El Forum - 07-03-2011, 04:46 PM
Global $data array? - by El Forum - 07-03-2011, 05:37 PM
Global $data array? - by El Forum - 07-03-2011, 06:38 PM
Global $data array? - by El Forum - 05-10-2012, 06:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB