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 7407557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:44:35+00:00 2026-05-29T05:44:35+00:00

For example this class: class A{ public function __call($func, $args){ if($func == ‘something’) call_user_func_array($this->_some_magic,

  • 0

For example this class:

class A{

  public function __call($func, $args){
    if($func == 'something')
      call_user_func_array($this->_some_magic, $args);
  }

  public function _some_magic(){
    ...
  }

  public static function something(){
    ...
  }

}

Now if I call $a::something() I want the something() method to run (like now).

But if I call $a->something() I want to trigger that undefined method stuff so I can do my magic, not something()…

Is there any way I can detect the way the method was called and execute the method I desire?

ps: I know I could do this using __callstatic and renaming something to something else, but I was wondering if there’s a better solution in which I can keep the current static method name

  • 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-05-29T05:44:36+00:00Added an answer on May 29, 2026 at 5:44 am

    See
    – __call http://www.php.net/manual/en/language.oop5.overloading.php#object.call
    – __callStatic http://www.php.net/manual/en/language.oop5.overloading.php#object.callstatic

    Or are you talking about determining whether its an external call e.g.:

    $a = new A();
    $a->doSomething();
    

    vs

    class A {
        public function doSomething() {}
        public function callDoSomething() { $this->doSomething(); }
    }
    

    If its the later case then I’d suggest simply making you internal class calls call another method which the external method call also routes to, e.g.:

    class A {
        public function doSomething() { $this->_doSomething(); }
        public function callDoSomething() { $this->_doSomething(); }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example I now created a this tiny class: public static class FileSystemInfoComparers<T> where
Example: Class A { public function __construct() { $this->b_Instance = new B(); } public
Please consider this example class: [Serializable] public class SomeClass { private DateTime _SomeDateTime; public
What does it mean to call a class like this: class Example { public:
Take this class as example: public class Category : PersistentObject<int> { public virtual string
take a look at this example code: public class Comment { private Comment() {
Take this sample class as an example: [AttributeUsage(AttributeTargets.All, AllowMultiple=true)] public class BugFixAttribute : System.Attribute
Consider this example: #include <iostream> class myclass { public: void print() { std::cout <<
This is an example of using ThrowawayController in Spring MVC: public class DisplayCourseController implements
Earlier I asked why this is considered bad: class Example { public: Example(void); ~Example(void);

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.