Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9254671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:31:50+00:00 2026-06-18T11:31:50+00:00

Might be I am missing something obvious. I have a native class with set

  • 0

Might be I am missing something obvious.
I have a native class with set and get method.

class DBStorage extends NativeClass{
  public function get($key);
  public function set($key,value);
}

I would like to use that most of the time, but, if I turn on the system DEBUG flag.
I would like the set and get methods to be overloaded with the following:

IF DEBUG IS ON{
    class DBStorage extends NativeClass{
      public function get($key){
         var_dump($key);
         parent::get($key);
      }
      public function set($key,$value){
         var_dump($key,$value);
         parent::set($key,$value);
      }
    }
}

NativeClass is written in C. It is an extension (phpredis, but it is not relevant).
How would I accomplish this?
I am on the 5.3 branch of PHP.

just to make sure…if debug is off, DBStorage will be:

 class DBStorage extends NativeClass{}

if debug is on, it will be:

class DBStorage extends NativeClass{
      public function get($key){
         var_dump($key);
         parent::get($key);
      }
      public function set($key,$value){
         var_dump($key,$value);
         parent::set($key,$value);
      }
    }

I do try to avoid the cluttring of IFs (there are dozens of functions in the real class)

public function get($key) {
       if (DEBUG) {
           var_dump($key);
       }
       return parent::get($key);
   }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:31:51+00:00Added an answer on June 18, 2026 at 11:31 am

    something just came to me

    class nodebug extends NativeClass{
      static public function create(){
            if(DEBUG) return new DebugNativeClass;
            return new self;
      }
    }
    
    class DebugNativeClass extends nodebug{
        public function set($key,$value){
           var_dump($key,$value);
           parent::set($key,$value);
        }
    
        public function get($key){
           var_dump($key);
           return parent::set($key);
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I might be missing something obvious here, but I'm implementing NSCopying on one of
I guess I might be missing something obvious here, but anyway lets see the
I've not used Spring too much, so I might be missing something obvious. Anyway,
I'm probably missing something really obvious. I've included <MediaPlayer/MediaPlayer.h> and have this code: NSURL
I don't have much of linux experience, so it might be I'm missing something
I am not particularly proficient in ASP, so I might be missing something obvious
I might be missing something obvious but is there a reference somewhere about what
I might be missing something obvious here, but I'm trying to define a route
I might be missing something really obvious. I'm trying to write a custom Panel
Surely I'm missing something pretty obvious... I have a field that is decimal with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.