Zen Cart Logo
Forums / General Questions / Please how do I get to a variable in a class

Please how do I get to a variable in a class

Locked

Views: 877

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
21 Mar 2008, 1:28 PM
#1
dayo avatar

dayo

Zen Follower

Join Date:
Dec 2006
Posts:
187
Plugin Contributions:
1

Please how do I get to a variable in a class

Hello

I have been working on the moneybookers module but hit a snag

I have created a variable in the class in the main module file as so...

  class moneybookers_gateway {
    var $code, $title, $description, $orders_table, $enabled;

    // class constructor
    function moneybookers_gateway() {
      
      etc etc etc ...
      
      $this->orders_table = DB_PREFIX . 'mbookers_gway_orders';
    }

using "$this->orders_table" within the same file works ok with no issues. However, I need to access this variable in another independent file but have been stymied so far.

The following debug code throws out a blank.

// load moneybookers module
require(DIR_WS_CLASSES . 'payment.php');
$moneybookers_gateway = new payment('moneybookers_gateway');
echo $moneybookers_gateway->orders_table;

Configure.php is loaded earlier so I know "DIR_WS_CLASSES" is defined.

Can anyone please give a pointer?

Thanks

21 Mar 2008, 1:53 PM
#2
dayo avatar

dayo

Zen Follower

Join Date:
Dec 2006
Posts:
187
Plugin Contributions:
1

Re: Please how do I get to a variable in a class

It needed the following instead

// load moneybookers module
require(DIR_WS_MODULES . 'path/to/module/file.php');
$moneybookers_gateway = new moneybookers_gateway;