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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:38:56+00:00 2026-05-22T21:38:56+00:00

I have some classes extended this way: class Baseresidence extends CActiveRecord { public static

  • 0

I have some classes extended this way:

class Baseresidence extends CActiveRecord {
    public static function model($className=__CLASS__) {
        return parent::model($className); // framework needs, can't modify
    }    
}

class Site1Residence extends Baseresidence {

}

and finally

class_alias('Site1Residence', 'Residence'); // this is part of an autoloader

So in the end I have like this Residence extends Site1Residence extends Baseresidence extends CActiveRecord

In the Baseresidence I have a static method model() which retrieves an instance.

Now I can call::

$r=Residence::model();

The problem is that __CLASS__ constant is used as default value, and that on that level is Baseresidence, and I need there the top level class name (created with the alias) and it should be ‘Residence’

if I do:

echo get_class($r); // the Baseresidence is printed

The goal is to print residence

I do not want to pass anything when calling $r=Residence::model(); I would like to resolve it on the roots.

How to get the top level class name on that level?

  • 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-22T21:38:57+00:00Added an answer on May 22, 2026 at 9:38 pm

    Try

    get_called_class();
    

    See http://php.net/manual/en/function.get-called-class.php

    From the docs:

    class foo {
        static public function test() {
            var_dump(get_called_class());
        }
    }
    
    class bar extends foo {
    }
    
    foo::test();
    bar::test();
    

    The above example will output:

    string(3) "foo"
    string(3) "bar"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some classes layed out like this class A { public virtual void
I have just implemented some classes: public abstract class Job<T extends ViewerUnion>{ [...] }
Say that i have some classes like this example. class A { int k,
Is there an easy way to do this. I have some classes annotated with
I have seen some C++ classes with a destructor defined as follows: class someClass
I have a base class vehicle and some children classes like car, motorbike etc..
I have the following existing classes: class Gaussian { public: virtual Vector get_mean() =
Lets say you have some functions in some classes are called together like this
I have some classes with the same super-type. Therefore all of this classes have
I have a utility class with some static methods which I use in some

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.