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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:57:43+00:00 2026-05-17T06:57:43+00:00

Is there any way to get the Derived Class Name from static Keyword ?

  • 0

Is there any way to get the Derived Class Name from static Keyword ?
What I actually want to do is.

Make a Reflection of the Derived Class
Check Wheather it implements the Specified Class or not

I’ve a static method the Base Class say its named Base::check()
I want Base::check() will check for the existence of the Interface Implementation.
the check() method knows the name of the interface.so I don’t need to tell it from outer world.

But if there is no way to get DerivedClassName from static Keyword I need to pass the Class Name to the method from the outer world. Which is not a good Coding Principle.

Another Alternative I can do is. I can make an ::instance() static method that returns the this and I can do a get_class from its return. But this also tweeks my Application Principle.

So is the first method really possible ? or I need to go for some alternative of this kind ?
Or Do you have any other kind of Alternatives ?

  • 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-17T06:57:43+00:00Added an answer on May 17, 2026 at 6:57 am

    I am not sure if I understand what you are trying to do, especially what you mean by “get the Derived Class Name from static Keyword“. Check out the following functions to see if they do what you want to do:

    • class_implements — Return the interfaces which are implemented by the given class
    • class_parents — Return the parent classes of the given class
    • is_a — Checks if the object is of this class or has this class as one of its parents
    • is_subclass_of — Checks if the object has this class as one of its parents
    • instanceof Type Operator

    If you are refering to Late Static binding, have a look at

    • get_called_class — the “Late Static Binding” class name

    I suppose you are trying to do something like this:

    class Base
    {
        public static function check()
        {
            return in_array('IFoo', class_implements(get_called_class(), FALSE));
            // or
            $instanceClassName = get_called_class();
            return new $instanceClassName instanceof IFoo;
            // or
            $reflector = new ReflectionClass(get_called_class());
            return $reflector->implementsInterface('IFoo');           
        }
    }
    interface IFoo {};
    class Foo extends Base implements IFoo {}
    
    var_dump( Foo::check() );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to get the column names from the pymssql results? If
Is there any way to get a color-int from a color resource? I am
Is there any way to get all user friend using Skype with C#? Also
Is there any way to get the screen size in pixels for a secondary
I have a base class Element and derived two other classes from it, Solid
I have a simple class derived from a generic list of string as follows:
How to get the path of the current class, from an inherited method? I
Is there a way to Invoke an overloaded method using reflection in .NET (2.0).
Possible Duplicate: .NET Is there a way to get the parent thread id? Is
I have an abstract class which I would like to be able to expose

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.