Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2006
    Posts
    163
    Plugin Contributions
    1

    Default 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...


    Code:
      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.
    Code:
    // 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

  2. #2
    Join Date
    Dec 2006
    Posts
    163
    Plugin Contributions
    1

    Default Solved

    It needed the following instead
    Code:
    // load moneybookers module
    require(DIR_WS_MODULES . 'path/to/module/file.php');
    $moneybookers_gateway = new moneybookers_gateway;

 

 

Similar Threads

  1. v154 Naming a global variable the same as a SESSION, GET or POST variable
    By torvista in forum General Questions
    Replies: 5
    Last Post: 6 Dec 2015, 11:11 AM
  2. Exporting tax class id into php variable
    By Dave_mck in forum General Questions
    Replies: 6
    Last Post: 8 Oct 2013, 09:40 PM
  3. v151 paypaldp.php: Invalid class variable
    By lat9 in forum Bug Reports
    Replies: 0
    Last Post: 27 May 2013, 07:41 PM
  4. Advanced Question - Class cannot store variable
    By jaycode in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 24 Aug 2007, 04:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR