Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Including a file in a PHP class

I was trying to figure out how I could manage the premium logic for my freemium Better Together for OpenCart module.  You can’t just require a block of code in the middle of a PHP Class:

class SomeClass {  
  // NOT ALLOWED! 
  premium_file = "premium.php";
  if (file_exists($premium_file)) {
    require($premium_file);
  }

So I cooked up another method that I documented in this StackOverflow post about how to include code into a PHP class.



This post first appeared on That Software Guy's Blog – Zen Cart And Other E-, please read the originial post: here

Share the post

Including a file in a PHP class

×

Subscribe to That Software Guy's Blog – Zen Cart And Other E-

Get updates delivered right to your inbox!

Thank you for your subscription

×