Jump to content

Recommended Posts

Posted

I know I can assign variables by using set or $config->var = something, but how do I set a configuration array? 

E.g. $config->site->theme

Posted

You could do:

$config->var = array('item' => 'val', 'item2' => 'val2');
 
echo $config->var['item2'];

Doesn't look as neat as you want, but should do the trick.

Posted

Kind of pointing out the obvious, but the code Pete posted creates config ARRAY, while interrobangs approach creates OBJECT.

It really doesn't matter which one you use here (especially considering that PHP array syntax isn't exactly pretty), just wanted to clarify the terminology a bit for any "OOP beginners" stumbling into this thread.. :)

  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...