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

  • SEARCH
  • Home
  • 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 7859007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:43:34+00:00 2026-06-02T21:43:34+00:00

Fairly certain this is not a duplicate… here it goes. My goal here is

  • 0

Fairly certain this is not a duplicate… here it goes.

My goal here is to overload multiple magic methods in a debug class, and have my main classes extend said class. My thought is this will allow me to have debugging step through the application stack, without me having to overload the magic methods in every class one by one.

So far the code looks something like this

class magicdbg
{
//data container object
private $data;

public function __construct()
{
    require_once("data.php");
    $this->data = data::defInstance();
}

public function __call($name,$arguments)
{
    echo "overloading call <br />";
    $this->data->dbgmsg("Calling method: " . __METHOD__ . " -- with arguments: (" .implode(',',$arguments) . ")");
}

public function __get($var)
{

}
}

and a class extending it

require_once("magicdbg.php");
class salesCtrl extends magicdbg
{
private $data;
public function __construct()
{
    require_once('data.php');
    $this->data = data::defInstance();
    $this->testcall();

}

private function testcall()
{
    echo "test";
}
}

and finally the class that contains the method that magicdbg is calling

class data
{
//application settings
CONST DEBUG = true;

//application messages
//debug messages
private $dbgmsgs;
private $errormsgs = array();
//application objects

//singleton object instance
private static $instance;

public function __construct()
{
    //if debug is enabled instantiate the debug message array
    if(self::DEBUG)
        $this->dbgmsgs = array();
}

public static function defInstance()
{
    echo "defining instance";
    if(!self::$instance)
        self::$instance = new data();

    echo "<br />instance defined<br />";
    return self::$instance;
}

public function dbgmsg($msg)
{
    echo "calling dbgmsg <br />";
    if(self::DEBUG)
        $this->dbgmsgs[] = $msg;
}

public function outputDbg()
{
    if(!self::DEBUG)
        return false;
    echo "testing dbg output <br />";
    $return = '<div id="debug"><ul>';
    foreach($this->dbgmsgs as $msg)
        $return .= "<li>" . $msg . "</li>";

    $return .= "</ul></div>";
    return $return;
}
}

the code is instantiated like so

require_once('sales.ctrl.php');
$ctrl = new salesCtrl();

and finally… my problem seems to be that it doesnt even hit the magic methods defined in the magicdbg class. I assume it doesnt work as I would expect. this might just be my lack of understanding of magic methods and overloading, as well as inheritance. can someone fill me in on what exactly is going wrong? or maybe even a better way to do what im intending?

  • 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-02T21:43:36+00:00Added an answer on June 2, 2026 at 9:43 pm

    _call is only executed for methods that are not defined in your class. It’s like a catch all for undefined methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am fairly certain this is a ten penny closure question. But having read
(I'm fairly certain the answer to this question is quite simply no but I
I'm fairly certain I'm having memory leaks using KO version 2.0. I have an
Per the code below, I am getting the following message. I am fairly certain
I’m fairly new at C# and MVC and have used lambdas on certain occasions,
fairly new iPhone developer here. Building an app to send RS232 commands to a
Fairly simple question: I have an init method on my class that has the
I have a feeling that this probably is not possible using strictly CSS, but,
Since this is a huge post here is a short summary (please read the
We're having a strange issue here. Unfortunately I'm not at liberty to post the

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.