Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2009
    Posts
    368
    Plugin Contributions
    0

    Default Load myclass.php only once

    I have myclass.php file .
    I want to load it just once and define a varible $myvar = new Myclass just once in order to use it on various pages .
    If I remember well myclass.php must be placed on includes/extra_configures , but I don't know where to define $myvar = new Myclass to be visible on every page .

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Load myclass.php only once

    Please explain what this "myclass" does, and how you intend to use it.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Aug 2009
    Posts
    368
    Plugin Contributions
    0

    Default Re: Load myclass.php only once

    myclass.php is a class that I want to use to see if session is mobile type and I need to instantiate it just once at the first visit .

  4. #4
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

    Default Re: Load myclass.php only once

    Put myclass.php into the /includes/classes/ folder.

    Then
    Create a new file:
    /includes/auto_loaders/config.solo_400.php
    Code:
      $autoLoadConfig[200][] = array('autoType'=>'class',
                                   'loadFile'=>'myclass.php');
    
      $autoLoadConfig[200][] = array('autoType'=>'classInstantiate',
                                   'className'=>'myClass',
                                   'objectName'=>'myClass',
                                   'checkInstantiated'=>true);
    Now $myClass will be the new instance of that class, and will be available in the global scope.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Aug 2009
    Posts
    368
    Plugin Contributions
    0

    Default Re: Load myclass.php only once

    Awesome. Thx Dr.

 

 

Similar Threads

  1. addon domain will only load with /inde.php
    By discoverytdi in forum Installing on a Linux/Unix Server
    Replies: 7
    Last Post: 13 Apr 2014, 02:22 PM
  2. Flash load only once per visit
    By funksdaburn in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 27 Nov 2007, 10:40 AM
  3. Displaying define_main.page.php only once
    By mdmerrell in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 23 Nov 2006, 04:49 PM
  4. Displaying define_main.page.php only once
    By mdmerrell in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 7 Sep 2006, 11:35 PM

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