inheirtence/extends assistance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm trying to move some code to an OO model.  In the existing code, i have
a config.inc.php file which is `require`d to set up all the needed
variables/values used in later functions/pages.  Currently, they are all
stored in arrays(4) and those arrays are made global and imported into
functions.

What i would like to do is have a base class which holds all the
configuration data, likely loaded by a method of that class to make for
easy user manipulation, but for now i'm hard coding the definitions to
understand the process.  I'm green to OO PHP, but am learning...or trying
to.

What i would like to do is:  (over simplified and *poorly* coded i realize)
      class config {
            var $main_cfg = array();
            var $main_cfg['install_root'] = '/path/to/install/directory';
      }

      class action extends config {
            function action() {
                  print $this->main_cfg['install_root'];
            }
      }

The config class does not need any methods, other then the constructor, but
only needs to be there to hold class variables.  All the examples that i've
found googling about 'extends' point to using methods of classes after
instantiating the subclass.  How do i access the parent class variables?
Am i thinking about this all wrong?

In the end, i'm trying to find the best way to make all my config values
accessible by all the classes that will be built, and i'm seeking help on
the best way to do that, which may not be what i described above.

Hopefully i've made sense.  I'm running php 4.3x and would like to keep the
syntax as such that it will run in the 4.x versions as this is for a piece
of software i host on sourceforge.net and i don't want to require an
upgrade to 5.0

many thanks in advance.
Jeff





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

PHP Data object relational mapping generator - http://www.meta-language.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux